convert -extent not working [Solved]

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?".
Post Reply
Flesh
Posts: 8
Joined: 2017-07-24T11:25:06-07:00
Authentication code: 1151

convert -extent not working [Solved]

Post by Flesh »

I have jpg images that are 4096x4096,
I want to extend the canvas 300 px on both sizes centering the image on the new canvas with transparent background for the new canvas only
So I do not want to change the original image, just pad it on both sides, and convert from jpg to png for transparency background.

This command will work without extending it:
convert in.jpg -alpha set -gravity center -extent 4096x4096 out.png

This one aborts with core dump
convert in.jpg -alpha set -gravity center -extent 4696x4096 out.png

I have tried -format png -resize 4096x4096
and Updated: -background none

mogrify also fails.

This will run as a bash command on over 100,000 files, so speed and quality is best

Running on Linux Manjaro (Arch Linux Clone)
convert -version
Version: ImageMagick 6.9.9-21 Q16 x86_64 2017-10-31 http://www.imagemagick.org
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png ps raw rsvg tiff webp wmf x xml zlib

Update: Upgrading to 7 fixed the issue.

Thanks
Last edited by Flesh on 2017-11-07T16:26:23-07:00, edited 2 times in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: convert -extent not working

Post by Bonzo »

Try:

Code: Select all

convert in.jpg -background none -gravity center -extent 4696x4096 out.png
Flesh
Posts: 8
Joined: 2017-07-24T11:25:06-07:00
Authentication code: 1151

Re: convert -extent not working

Post by Flesh »

Thanks, but it did not help.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: convert -extent not working

Post by Bonzo »

I recommend you try my code on a different computer/server and see if it works.
Thanks, but it did not help.
What did or did not happen?
Flesh
Posts: 8
Joined: 2017-07-24T11:25:06-07:00
Authentication code: 1151

Re: convert -extent not working

Post by Flesh »

That was it, just this machine, the other is setup the same, tired to reinstall imagemagick, no help; so this sucks.
It might be related to this:
https://www.imagemagick.org/discourse-s ... hp?t=24603
I am using opencl-nvidia for cuda in blender; just a guess, but I have it on the other machine also; the only difference I see in machines is AMD vs Intel, and its the Intel machine that is breaking, an i7.

I did need -background none, or its white by default.

Thanks, I should have tried this first, so many times this has bitten me.
Flesh
Posts: 8
Joined: 2017-07-24T11:25:06-07:00
Authentication code: 1151

Re: convert -extent not working [Solved]

Post by Flesh »

Upgrading to 7 fixed it.
Post Reply