export_fig crop to specific dimensions
Afficher commentaires plus anciens
I would like to save a figure with a specific DPI and size. In particular, I would like the photo to be 1080 px wide x 270 px high with a dpi of 350.
I have tried using the crop part of export_fig (and changing the NaN to specific numbers) but it has not produced what I need.
export_fig('test','-png','-c[NaN,NaN,NaN,NaN]', '-r350');
I'd appreciate any tips!
2 commentaires
Rik
le 1 Août 2022
If you first export the pixels, you can write it to a file that allows setting a dpi. Personally I think DPI hardly ever makes sense to specify, since the pixels define the actual image data.
Walter Roberson
le 1 Août 2022
Modifié(e) : Walter Roberson
le 1 Août 2022
In order to get a resolution stored inside a png file, there are two possibilities:
- png files natively support storing a Resolution Unit, and x and y resolutions per unit. If you imwrite() then the option names are ResolutionUnit and XResolution and YResolution. It would not astonish me at all if export_fig does not know to write the fields.
- since 2017 the revised png specification have supported using an Exif chunk to write Exif attributes. MATLAB itself does not support adding Exif to any file format, and I suspect that export_fig does not do so either .
If neither of these happens then resolution information will not appear in the png file .
These days you would use newer matlab routines to copy the graphics, and then you would imwrite the data file passing in the resolution information .
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
