How convert jpg change dpi

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
wangyongjun
Posts: 36
Joined: 2019-10-23T02:01:57-07:00
Authentication code: 1152

How convert jpg change dpi

Post by wangyongjun »

dpi 96 . How can change it to 300

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How convert jpg change dpi

Post by snibgo »

With "-density 300".
snibgo's IM pages: im.snibgo.com

wangyongjun
Posts: 36
Joined: 2019-10-23T02:01:57-07:00
Authentication code: 1152

Re: How convert jpg change dpi

Post by wangyongjun »

a.jpg Image size 6969*9331 dpi: 300
convert a.jpg -density 350 -resize 5973x7998 b.jpg
check b.jpg dpi still 300 . resize effected

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How convert jpg change dpi

Post by snibgo »

What version of IM, on what platform?

Please show your exact commands.

It works fine for me, with IM v7.0.8-64 on Windows 8.1:

Code: Select all

%IMG7%magick -size 6969x9331 -density 300 -units PixelsPerInch xc: a.jpg

%IMG7%magick identify -format "%%f %%x %%y %%U\n" a.jpg

%IMG7%magick a.jpg -density 350 -resize 5973x7998 b.jpg

%IMG7%magick identify -format "%%f %%x %%y %%U\n" b.jpg
The outputs are:

Code: Select all

a.jpg 300 300 PixelsPerInch

b.jpg 350 350 PixelsPerInch
snibgo's IM pages: im.snibgo.com

wangyongjun
Posts: 36
Joined: 2019-10-23T02:01:57-07:00
Authentication code: 1152

Re: How convert jpg change dpi

Post by wangyongjun »

Version: ImageMagick 6.7.8-9 2019-08-08 Q16 CentOS7
There seems has no magick cmd on linux
[wangyongjun@fm-mgt-88 Image-ExifTool-11.93]$ magick identify -format "%%f %%x %%y %%U\n" ../rgb_2.jpg
-bash: magick: command not found

wangyongjun
Posts: 36
Joined: 2019-10-23T02:01:57-07:00
Authentication code: 1152

Re: How convert jpg change dpi

Post by wangyongjun »

and I use ExifTool to check dpi(X Resolution)

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How convert jpg change dpi

Post by snibgo »

For v6, use "convert" instead of "magick".

Your 6.7.8-9 is very very old. It may have a bug for "-density". I suggest you upgrade.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: How convert jpg change dpi

Post by fmw42 »

IM 6.7.8.9 is known to be buggy.

Locked