Maurício Linhares
Maurício Linhares

Reputation: 40333

imagemagick convert command generating lots of images instead of just one

I am calling the following command from a Java app:

/usr/bin/convert "companies.png" -strip -quality 67 -density 92 -resize "300x>" -crop "300x300>" -format png result.png

But instead of getting one image back, cropped at 300x300 after being resized, I'm getting six slices of the same image, each 300px tall, which isn't exactly what I was expecting.

Any idea on how I could change this command to just get one image? This is a backend service, so having something that generates an unknown amount of images isn't really ideal.

The original image is available here

Upvotes: 0

Views: 259

Answers (3)

rscarvalho
rscarvalho

Reputation: 552

you just need to add the option -delete 1--1 to the argument list. This way you will delete the range of indexes from 1 (the first image of the sequence) to -1 (the last image of the sequence). The result will be a single result.png file.

The command line will be something like this:

convert original.png -strip -quality 67 -density 92 -resize '300x>' -crop '300x300>' -format png -delete 1--1 result.png

Upvotes: 1

Paul Rubel
Paul Rubel

Reputation: 27252

I see the same thing. However, ff I convert to a jpg first

convert companies.png companies.jpg

then run your command on the new jpg only one file comes out (jpg or png output behave the same with jpg input). It's odd that the input format seems to matter.

/usr/bin/convert "companies.jpg" -strip -quality 67 \
  -density 92 -resize "300x>" -crop "300x300>" \
  -format png result.png  #-> one file result.png

Upvotes: 1

Leonardo Eloy
Leonardo Eloy

Reputation: 2793

It should work with this:

/usr/bin/convert "companies.png" -strip -quality 67 -density 92 -resize "300x>" -crop "300x300>+0+0" -format png result.png

Upvotes: 2

Related Questions