Resize an Image while preserving aspect ratio in MATLAB Report Generator R2018a
15 views (last 30 days)
Show older comments
MathWorks Support Team
on 4 Jan 2019
Edited: MathWorks Support Team
on 18 Apr 2019
I would like to resize my image in MATLAB Report Generator but preserve the aspect ratio. I am using the method described in the link below, but I have not found an easy way to preserve the aspect ratio.
Accepted Answer
MathWorks Support Team
on 19 Apr 2019
Edited: MathWorks Support Team
on 18 Apr 2019
See the example which shows how if you only specify the "Height" in the "<image>.Style" property and not the "Width", then the aspect ratio is preserved.
import mlreportgen.dom.*
%create document
d = Document('imageArea2','pdf');
%create two images, origional and resized
img_orig = Image('circle.png');
img_resize = Image('circle.png');
%resize one image
img_resize.Style = {Height('2.5in')}; %the new height we want in inches
%add both to document and view
append(d,img_orig);
append(d,img_resize);
close(d);
rptview(d.OutputPath);
0 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB Report Generator in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!