Using Glide, is it possible to get output image resolution, before the actual decoding and saving into a...
Background
I'm trying to have a horizontally scrolling effect on any given image file in a live wallpaper app.
For this, I should work according to these rules, I think:
- Input is an image file of any resolution
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Output bitmap should be up to a certain width, because I don't want to make a too large bitmap, taking huge amount of memory
- Keep the aspect ratio no matter what.
The problem
I'm finding difficulties finding the correct functions and parameters to make it generate the proper width&height of the output bitmap.
What I've tried
I've tried messing around with various transformations (example: centerCropTransform,fitCenterTransform) , but none of those reached what I wanted, so I think that none can work unless I do some special math on my side before deciding what to do with Glide.
Currently what I do is something like that:
val result = Glide.with(context).asBitmap()
.load(imageFile)
.apply(RequestOptions.noTransformation()
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, reqHeight).get()
This works, as it produces (at least according to my tests) a bitmap that is at least of the size I request it to be. However, it means I have extra pixels that aren't really needed for the height. It also doesn't protect me from generating a too large bitmap.
But I think maybe it would be easier to ask Glide to use various techniques for the above purpose, and then decide on the possible output resolutions, which is the best to use.
The questions
Is it possible to get the output resolution before the actual decoding&storing into a bitmap, and only later decide which technique should be used?
Is there maybe a better option I should consider ? Maybe do the calculation on my side, and then decide what to do with Glide? If so, how?
android bitmap scale crop glide
add a comment |
Background
I'm trying to have a horizontally scrolling effect on any given image file in a live wallpaper app.
For this, I should work according to these rules, I think:
- Input is an image file of any resolution
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Output bitmap should be up to a certain width, because I don't want to make a too large bitmap, taking huge amount of memory
- Keep the aspect ratio no matter what.
The problem
I'm finding difficulties finding the correct functions and parameters to make it generate the proper width&height of the output bitmap.
What I've tried
I've tried messing around with various transformations (example: centerCropTransform,fitCenterTransform) , but none of those reached what I wanted, so I think that none can work unless I do some special math on my side before deciding what to do with Glide.
Currently what I do is something like that:
val result = Glide.with(context).asBitmap()
.load(imageFile)
.apply(RequestOptions.noTransformation()
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, reqHeight).get()
This works, as it produces (at least according to my tests) a bitmap that is at least of the size I request it to be. However, it means I have extra pixels that aren't really needed for the height. It also doesn't protect me from generating a too large bitmap.
But I think maybe it would be easier to ask Glide to use various techniques for the above purpose, and then decide on the possible output resolutions, which is the best to use.
The questions
Is it possible to get the output resolution before the actual decoding&storing into a bitmap, and only later decide which technique should be used?
Is there maybe a better option I should consider ? Maybe do the calculation on my side, and then decide what to do with Glide? If so, how?
android bitmap scale crop glide
are you reading the image from local storage? If yes, then I think you can get the info from the file itself i.e width and height to be loaded
– Gautam
Jan 2 at 17:45
@Gautam I already know how to get the resolution of an image file without decoding it (usinginJustDecodeBounds=true
for theBitmapFactory.Options
that is sent toBitmapFactory.decodeFile
) . The question was about the output file of Glide, before it will actually decode the input file and create the output image. I don't want to perform un-needed operations...
– android developer
Jan 2 at 17:56
add a comment |
Background
I'm trying to have a horizontally scrolling effect on any given image file in a live wallpaper app.
For this, I should work according to these rules, I think:
- Input is an image file of any resolution
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Output bitmap should be up to a certain width, because I don't want to make a too large bitmap, taking huge amount of memory
- Keep the aspect ratio no matter what.
The problem
I'm finding difficulties finding the correct functions and parameters to make it generate the proper width&height of the output bitmap.
What I've tried
I've tried messing around with various transformations (example: centerCropTransform,fitCenterTransform) , but none of those reached what I wanted, so I think that none can work unless I do some special math on my side before deciding what to do with Glide.
Currently what I do is something like that:
val result = Glide.with(context).asBitmap()
.load(imageFile)
.apply(RequestOptions.noTransformation()
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, reqHeight).get()
This works, as it produces (at least according to my tests) a bitmap that is at least of the size I request it to be. However, it means I have extra pixels that aren't really needed for the height. It also doesn't protect me from generating a too large bitmap.
But I think maybe it would be easier to ask Glide to use various techniques for the above purpose, and then decide on the possible output resolutions, which is the best to use.
The questions
Is it possible to get the output resolution before the actual decoding&storing into a bitmap, and only later decide which technique should be used?
Is there maybe a better option I should consider ? Maybe do the calculation on my side, and then decide what to do with Glide? If so, how?
android bitmap scale crop glide
Background
I'm trying to have a horizontally scrolling effect on any given image file in a live wallpaper app.
For this, I should work according to these rules, I think:
- Input is an image file of any resolution
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Output bitmap should be up to a certain width, because I don't want to make a too large bitmap, taking huge amount of memory
- Keep the aspect ratio no matter what.
The problem
I'm finding difficulties finding the correct functions and parameters to make it generate the proper width&height of the output bitmap.
What I've tried
I've tried messing around with various transformations (example: centerCropTransform,fitCenterTransform) , but none of those reached what I wanted, so I think that none can work unless I do some special math on my side before deciding what to do with Glide.
Currently what I do is something like that:
val result = Glide.with(context).asBitmap()
.load(imageFile)
.apply(RequestOptions.noTransformation()
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, reqHeight).get()
This works, as it produces (at least according to my tests) a bitmap that is at least of the size I request it to be. However, it means I have extra pixels that aren't really needed for the height. It also doesn't protect me from generating a too large bitmap.
But I think maybe it would be easier to ask Glide to use various techniques for the above purpose, and then decide on the possible output resolutions, which is the best to use.
The questions
Is it possible to get the output resolution before the actual decoding&storing into a bitmap, and only later decide which technique should be used?
Is there maybe a better option I should consider ? Maybe do the calculation on my side, and then decide what to do with Glide? If so, how?
android bitmap scale crop glide
android bitmap scale crop glide
asked Jan 1 at 18:03
android developerandroid developer
54.3k98472877
54.3k98472877
are you reading the image from local storage? If yes, then I think you can get the info from the file itself i.e width and height to be loaded
– Gautam
Jan 2 at 17:45
@Gautam I already know how to get the resolution of an image file without decoding it (usinginJustDecodeBounds=true
for theBitmapFactory.Options
that is sent toBitmapFactory.decodeFile
) . The question was about the output file of Glide, before it will actually decode the input file and create the output image. I don't want to perform un-needed operations...
– android developer
Jan 2 at 17:56
add a comment |
are you reading the image from local storage? If yes, then I think you can get the info from the file itself i.e width and height to be loaded
– Gautam
Jan 2 at 17:45
@Gautam I already know how to get the resolution of an image file without decoding it (usinginJustDecodeBounds=true
for theBitmapFactory.Options
that is sent toBitmapFactory.decodeFile
) . The question was about the output file of Glide, before it will actually decode the input file and create the output image. I don't want to perform un-needed operations...
– android developer
Jan 2 at 17:56
are you reading the image from local storage? If yes, then I think you can get the info from the file itself i.e width and height to be loaded
– Gautam
Jan 2 at 17:45
are you reading the image from local storage? If yes, then I think you can get the info from the file itself i.e width and height to be loaded
– Gautam
Jan 2 at 17:45
@Gautam I already know how to get the resolution of an image file without decoding it (using
inJustDecodeBounds=true
for the BitmapFactory.Options
that is sent to BitmapFactory.decodeFile
) . The question was about the output file of Glide, before it will actually decode the input file and create the output image. I don't want to perform un-needed operations...– android developer
Jan 2 at 17:56
@Gautam I already know how to get the resolution of an image file without decoding it (using
inJustDecodeBounds=true
for the BitmapFactory.Options
that is sent to BitmapFactory.decodeFile
) . The question was about the output file of Glide, before it will actually decode the input file and create the output image. I don't want to perform un-needed operations...– android developer
Jan 2 at 17:56
add a comment |
2 Answers
2
active
oldest
votes
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Keep the aspect ratio no matter what.
You can't really hold all of these to be true, because if you have a guaranteed minimum height and a guaranteed minimum width, then you might have to distort the aspect ratio, which violates the third condition.
I'd recommend having these three conditions instead:
- Set max height of output to height of device screen (in portrait)
- Set maximum allocated memory of output bitmap
- Maintain original aspect ratio no matter what
Glide can do 1 and 3 for you but 2 you might need to first decode the bitmap without allocating memory (look at BitmapFactory.Options.inJustDecodeBounds
) to get the source aspect ratio then use math to figure out what height and width to set so you don't go over your per-bitmap memory ceiling.
Last thing though, depending on your use case (if you need to render multiple bitmaps in a short amount of time), you might want to consider cropping to a standard output aspect ratio so you can take advantage of Glide's bitmap recycling feature, which helps avoid OOM crashes.
Why would I have to "distort the aspect ratio" ? I've just written that it's ok if it gets cropped ("scale/crop"). Cropping means that you can still see the image in its original aspect ratio, but just can't see some part/s of the image. Using center-crop, I can actually fit any image into any resolution. Cropping should be done only if scaling didn't work, though. I don't understand your suggestion, but seeing you reduced what I wrote, I don't want to use it. The code I wrote seem to work fine, but it's just not getting cropped or limited by width.
– android developer
Jan 1 at 19:34
add a comment |
OK I think I got it.
I calculate what will happen if I fit to width and to height, and use center crop on the calculated result accordingly:
val bitmapOptions = Utils.getBitmapOptions(savedImageFileForWallpaperBackground.absolutePath)
//newWidth/newHeight=oldWidth/oldHeight
val widthIfScaledToHeight = reqHeight * bitmapOptions.outWidth / bitmapOptions.outHeight
val heightIfScaledToWidth = reqWidth * bitmapOptions.outHeight / bitmapOptions.outWidth
val result: Bitmap
if (widthIfScaledToHeight >= reqWidth) {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(widthIfScaledToHeight, reqHeight).get()
} else {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, heightIfScaledToWidth).get()
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53997717%2fusing-glide-is-it-possible-to-get-output-image-resolution-before-the-actual-de%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Keep the aspect ratio no matter what.
You can't really hold all of these to be true, because if you have a guaranteed minimum height and a guaranteed minimum width, then you might have to distort the aspect ratio, which violates the third condition.
I'd recommend having these three conditions instead:
- Set max height of output to height of device screen (in portrait)
- Set maximum allocated memory of output bitmap
- Maintain original aspect ratio no matter what
Glide can do 1 and 3 for you but 2 you might need to first decode the bitmap without allocating memory (look at BitmapFactory.Options.inJustDecodeBounds
) to get the source aspect ratio then use math to figure out what height and width to set so you don't go over your per-bitmap memory ceiling.
Last thing though, depending on your use case (if you need to render multiple bitmaps in a short amount of time), you might want to consider cropping to a standard output aspect ratio so you can take advantage of Glide's bitmap recycling feature, which helps avoid OOM crashes.
Why would I have to "distort the aspect ratio" ? I've just written that it's ok if it gets cropped ("scale/crop"). Cropping means that you can still see the image in its original aspect ratio, but just can't see some part/s of the image. Using center-crop, I can actually fit any image into any resolution. Cropping should be done only if scaling didn't work, though. I don't understand your suggestion, but seeing you reduced what I wrote, I don't want to use it. The code I wrote seem to work fine, but it's just not getting cropped or limited by width.
– android developer
Jan 1 at 19:34
add a comment |
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Keep the aspect ratio no matter what.
You can't really hold all of these to be true, because if you have a guaranteed minimum height and a guaranteed minimum width, then you might have to distort the aspect ratio, which violates the third condition.
I'd recommend having these three conditions instead:
- Set max height of output to height of device screen (in portrait)
- Set maximum allocated memory of output bitmap
- Maintain original aspect ratio no matter what
Glide can do 1 and 3 for you but 2 you might need to first decode the bitmap without allocating memory (look at BitmapFactory.Options.inJustDecodeBounds
) to get the source aspect ratio then use math to figure out what height and width to set so you don't go over your per-bitmap memory ceiling.
Last thing though, depending on your use case (if you need to render multiple bitmaps in a short amount of time), you might want to consider cropping to a standard output aspect ratio so you can take advantage of Glide's bitmap recycling feature, which helps avoid OOM crashes.
Why would I have to "distort the aspect ratio" ? I've just written that it's ok if it gets cropped ("scale/crop"). Cropping means that you can still see the image in its original aspect ratio, but just can't see some part/s of the image. Using center-crop, I can actually fit any image into any resolution. Cropping should be done only if scaling didn't work, though. I don't understand your suggestion, but seeing you reduced what I wrote, I don't want to use it. The code I wrote seem to work fine, but it's just not getting cropped or limited by width.
– android developer
Jan 1 at 19:34
add a comment |
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Keep the aspect ratio no matter what.
You can't really hold all of these to be true, because if you have a guaranteed minimum height and a guaranteed minimum width, then you might have to distort the aspect ratio, which violates the third condition.
I'd recommend having these three conditions instead:
- Set max height of output to height of device screen (in portrait)
- Set maximum allocated memory of output bitmap
- Maintain original aspect ratio no matter what
Glide can do 1 and 3 for you but 2 you might need to first decode the bitmap without allocating memory (look at BitmapFactory.Options.inJustDecodeBounds
) to get the source aspect ratio then use math to figure out what height and width to set so you don't go over your per-bitmap memory ceiling.
Last thing though, depending on your use case (if you need to render multiple bitmaps in a short amount of time), you might want to consider cropping to a standard output aspect ratio so you can take advantage of Glide's bitmap recycling feature, which helps avoid OOM crashes.
- I should scale/crop so that the height will be of a specific value.
- The width should be at least of a specific value
- Keep the aspect ratio no matter what.
You can't really hold all of these to be true, because if you have a guaranteed minimum height and a guaranteed minimum width, then you might have to distort the aspect ratio, which violates the third condition.
I'd recommend having these three conditions instead:
- Set max height of output to height of device screen (in portrait)
- Set maximum allocated memory of output bitmap
- Maintain original aspect ratio no matter what
Glide can do 1 and 3 for you but 2 you might need to first decode the bitmap without allocating memory (look at BitmapFactory.Options.inJustDecodeBounds
) to get the source aspect ratio then use math to figure out what height and width to set so you don't go over your per-bitmap memory ceiling.
Last thing though, depending on your use case (if you need to render multiple bitmaps in a short amount of time), you might want to consider cropping to a standard output aspect ratio so you can take advantage of Glide's bitmap recycling feature, which helps avoid OOM crashes.
answered Jan 1 at 18:44
johnheroyjohnheroy
32615
32615
Why would I have to "distort the aspect ratio" ? I've just written that it's ok if it gets cropped ("scale/crop"). Cropping means that you can still see the image in its original aspect ratio, but just can't see some part/s of the image. Using center-crop, I can actually fit any image into any resolution. Cropping should be done only if scaling didn't work, though. I don't understand your suggestion, but seeing you reduced what I wrote, I don't want to use it. The code I wrote seem to work fine, but it's just not getting cropped or limited by width.
– android developer
Jan 1 at 19:34
add a comment |
Why would I have to "distort the aspect ratio" ? I've just written that it's ok if it gets cropped ("scale/crop"). Cropping means that you can still see the image in its original aspect ratio, but just can't see some part/s of the image. Using center-crop, I can actually fit any image into any resolution. Cropping should be done only if scaling didn't work, though. I don't understand your suggestion, but seeing you reduced what I wrote, I don't want to use it. The code I wrote seem to work fine, but it's just not getting cropped or limited by width.
– android developer
Jan 1 at 19:34
Why would I have to "distort the aspect ratio" ? I've just written that it's ok if it gets cropped ("scale/crop"). Cropping means that you can still see the image in its original aspect ratio, but just can't see some part/s of the image. Using center-crop, I can actually fit any image into any resolution. Cropping should be done only if scaling didn't work, though. I don't understand your suggestion, but seeing you reduced what I wrote, I don't want to use it. The code I wrote seem to work fine, but it's just not getting cropped or limited by width.
– android developer
Jan 1 at 19:34
Why would I have to "distort the aspect ratio" ? I've just written that it's ok if it gets cropped ("scale/crop"). Cropping means that you can still see the image in its original aspect ratio, but just can't see some part/s of the image. Using center-crop, I can actually fit any image into any resolution. Cropping should be done only if scaling didn't work, though. I don't understand your suggestion, but seeing you reduced what I wrote, I don't want to use it. The code I wrote seem to work fine, but it's just not getting cropped or limited by width.
– android developer
Jan 1 at 19:34
add a comment |
OK I think I got it.
I calculate what will happen if I fit to width and to height, and use center crop on the calculated result accordingly:
val bitmapOptions = Utils.getBitmapOptions(savedImageFileForWallpaperBackground.absolutePath)
//newWidth/newHeight=oldWidth/oldHeight
val widthIfScaledToHeight = reqHeight * bitmapOptions.outWidth / bitmapOptions.outHeight
val heightIfScaledToWidth = reqWidth * bitmapOptions.outHeight / bitmapOptions.outWidth
val result: Bitmap
if (widthIfScaledToHeight >= reqWidth) {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(widthIfScaledToHeight, reqHeight).get()
} else {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, heightIfScaledToWidth).get()
}
add a comment |
OK I think I got it.
I calculate what will happen if I fit to width and to height, and use center crop on the calculated result accordingly:
val bitmapOptions = Utils.getBitmapOptions(savedImageFileForWallpaperBackground.absolutePath)
//newWidth/newHeight=oldWidth/oldHeight
val widthIfScaledToHeight = reqHeight * bitmapOptions.outWidth / bitmapOptions.outHeight
val heightIfScaledToWidth = reqWidth * bitmapOptions.outHeight / bitmapOptions.outWidth
val result: Bitmap
if (widthIfScaledToHeight >= reqWidth) {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(widthIfScaledToHeight, reqHeight).get()
} else {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, heightIfScaledToWidth).get()
}
add a comment |
OK I think I got it.
I calculate what will happen if I fit to width and to height, and use center crop on the calculated result accordingly:
val bitmapOptions = Utils.getBitmapOptions(savedImageFileForWallpaperBackground.absolutePath)
//newWidth/newHeight=oldWidth/oldHeight
val widthIfScaledToHeight = reqHeight * bitmapOptions.outWidth / bitmapOptions.outHeight
val heightIfScaledToWidth = reqWidth * bitmapOptions.outHeight / bitmapOptions.outWidth
val result: Bitmap
if (widthIfScaledToHeight >= reqWidth) {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(widthIfScaledToHeight, reqHeight).get()
} else {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, heightIfScaledToWidth).get()
}
OK I think I got it.
I calculate what will happen if I fit to width and to height, and use center crop on the calculated result accordingly:
val bitmapOptions = Utils.getBitmapOptions(savedImageFileForWallpaperBackground.absolutePath)
//newWidth/newHeight=oldWidth/oldHeight
val widthIfScaledToHeight = reqHeight * bitmapOptions.outWidth / bitmapOptions.outHeight
val heightIfScaledToWidth = reqWidth * bitmapOptions.outHeight / bitmapOptions.outWidth
val result: Bitmap
if (widthIfScaledToHeight >= reqWidth) {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(widthIfScaledToHeight, reqHeight).get()
} else {
result = Glide.with(wallpaperService).asBitmap()
.load(savedImageFileForWallpaperBackground)
.apply(RequestOptions.centerCropTransform().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE))
.submit(reqWidth, heightIfScaledToWidth).get()
}
answered Jan 16 at 18:06
android developerandroid developer
54.3k98472877
54.3k98472877
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53997717%2fusing-glide-is-it-possible-to-get-output-image-resolution-before-the-actual-de%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
are you reading the image from local storage? If yes, then I think you can get the info from the file itself i.e width and height to be loaded
– Gautam
Jan 2 at 17:45
@Gautam I already know how to get the resolution of an image file without decoding it (using
inJustDecodeBounds=true
for theBitmapFactory.Options
that is sent toBitmapFactory.decodeFile
) . The question was about the output file of Glide, before it will actually decode the input file and create the output image. I don't want to perform un-needed operations...– android developer
Jan 2 at 17:56