GetImageDimensions can crash Mendix app when processing high resolution images#126
Open
klatter wants to merge 1 commit intomendix:masterfrom
Open
GetImageDimensions can crash Mendix app when processing high resolution images#126klatter wants to merge 1 commit intomendix:masterfrom
klatter wants to merge 1 commit intomendix:masterfrom
Conversation
klatter
commented
Aug 30, 2022
| // BEGIN USER CODE | ||
| ImageDimensions imageDimensions = new ImageDimensions(getContext()); | ||
| try (InputStream inputStream = Core.getImage(getContext(), this.ImageParameter.getMendixObject(), false)) { | ||
| BufferedImage bimg = ImageIO.read(inputStream); |
Author
There was a problem hiding this comment.
The ImageIo.read method reads the whole inputstream.
klatter
commented
Aug 30, 2022
|
|
||
| try { | ||
| reader.setInput(imageStream); | ||
| int height = reader.getHeight(reader.getMinIndex()); |
Author
There was a problem hiding this comment.
The PNG, JPG and BMP ImageReader implementations only read the imageheader to determine the height and width.
ad750d8 to
f63b15e
Compare
fc75a53 to
14640f7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current version of GetImageDimensions makes use of Java's BufferedImage, which loads the image uncompressed into memory. This can cause an out of memory exception using this java action with a a high resolution image.
The new implementation is based on the stackoverflow post below and avoids loading the image uncompressed into memory.
https://stackoverflow.com/questions/672916/how-to-get-image-height-and-width-using-java