Resize AND convert *.jpg to *.png possible in one command?

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
bensto
Posts: 33
Joined: 2012-07-02T00:32:10-07:00
Authentication code: 13

Resize AND convert *.jpg to *.png possible in one command?

Post by bensto »

I have *.jpg pictures which I can resize successfuly with a command similar to:

convert myorigpic.jpg -resize 1280x -quality 97 myresizedpic.jpg

Is there a way to (lossless) convert (in the same command!) the JPG format to PNG (immediately after the resize operation)?
Or are there two command necessary?

How would such a command look like?

Ben

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

Re: Resize AND convert *.jpg to *.png possible in one command?

Post by fmw42 »

Not sure what you want to do, but this will take the decompressed jpg from the read, resize it and save it to png without losslessly recompressing in jpg format. It will be compressed to png format, but that is lossless.

Code: Select all

convert myorigpic.jpg -resize 1280x myresizedpic.png

bensto
Posts: 33
Joined: 2012-07-02T00:32:10-07:00
Authentication code: 13

Re: Resize AND convert *.jpg to *.png possible in one command?

Post by bensto »

Danke.

Wird zuerst das Resize durchgeführt und dann das convert JPG--->PNG oder umgekehrt?

Ich könnte mir vorstellen, dass eine Konvertierung zunächst in PNG und dann erst das Resize ein besseres Ergebnis erzietl

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

Re: Resize AND convert *.jpg to *.png possible in one command?

Post by fmw42 »

The command that I provided simply reads the input jpg and decompresses it into a 24-bit color image. Then it resizes it. Then it saves to PNG with lossless compress. If you want to go to JPG, it will not matter whether you use intermediate PNG or not. The quality will be lost by the writing of a new PNG due to the lossy compression.

Locked