Saving figure in jpg with 600 dpi

46 ビュー (過去 30 日間)
Erfan Basiri
Erfan Basiri 2022 年 10 月 22 日
コメント済み: Erfan Basiri 2022 年 10 月 28 日
Hi
After saving a jpg image using the code below, the dpi isn't 600 in the details tab of the image properties! Actually, it is written 96 dpi.
exportgraphics(gcf,'DM1.jpg','Resolution','600')
Is it ok or sth should be changed to get 600 dpi image?
I should add that there isn't such a problem in case of tiff, and when saving in tiff with a specefic resolution, I see exactly that dpi I used.
Thanks

採用された回答

Steve Eddins
Steve Eddins 2022 年 10 月 25 日
The function exportgraphics generates and saves the image at the specified resolution, but it does not write resolution info into a JPEG file's metadata. The "96" you are seeing is probably just some default value that is populated in the image properties tab when a file does not contain that metadata.
Under the hood, exportgraphics uses imwrite to create TIFF, JPEG, PNG, and GIF files, and imwrite does not support resolution metadata for JPEG files. It does support resolution metadata for TIFF and PNG files, and so exportgraphics will write the specified resolution to a TIFF or PNG file.
The JPEG File Interchange Format (JFIF) spec does include a way to include resolution information, but I have the impression that resolution metadata is not as widely used for JPEG as it is for TIFF and PNG, which are more commonly used in print publishing applications than JPEG. JPEG is not as suitable for print publishing. If you are generating a 600 dpi file, then I imagine it is for a print publishing application, and then I would recommend using TIFF or PNG anyway, since JPEG compression is lossy.
I did find an enhancement request in our system for writing resolution info to JPEG files using imwrite. I'll add a note to it about this thread.
  1 件のコメント
Erfan Basiri
Erfan Basiri 2022 年 10 月 28 日
Thank you for providing the detailed answer.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2022 年 10 月 22 日
  3 件のコメント
DGM
DGM 2022 年 10 月 24 日
As far as I know, MATLAB doesn't bother with EXIF data on write. The number in the "resolution" tag has no effect on image data. If you want to write some arbitrary number in that field, you could use exiftool or some other external editor. If you have it, you could always call exiftool via system().
Erfan Basiri
Erfan Basiri 2022 年 10 月 28 日
Thank you for the detailed answer.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by