Reduce canvas size non-destructively

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
Bird
Posts: 5
Joined: 2020-03-26T11:38:33-07:00
Authentication code: 1152

Reduce canvas size non-destructively

Post by Bird »

I need to be able to reduce the canvas size of a psd without losing the out-of-bounds layer information.

Like this:
Image

magick in.png -resize 500x -gravity center -extent 500x500 out.psd
doesn't work.

What am I doing wrong?
Last edited by Bird on 2020-03-26T12:32:25-07:00, edited 1 time in total.

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

Re: Reduce canvas size non-destructively

Post by fmw42 »

Your question is not clear. I do not understand exactly what you want. Post the original image without the guide lines that has layer information. Then show the result you want. Is the layer information the virtual canvas information that you need?

Bird
Posts: 5
Joined: 2020-03-26T11:38:33-07:00
Authentication code: 1152

Re: Reduce canvas size non-destructively

Post by Bird »

This is the original image. The image size equals the canvas size.
Image

Using -extent sets the canvas size properly, but any layer information out-of-bounds is erased.
Image

I want to be able to reduce the canvas size without cropping the layer size. Yellow dashed line is the layer boundary.
Image

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

Re: Reduce canvas size non-destructively

Post by fmw42 »

Your input in you command is a PNG. It does not have layer information. Did you mean PSD?

ImageMagick is limited in what it can do with PSD files.

Bird
Posts: 5
Joined: 2020-03-26T11:38:33-07:00
Authentication code: 1152

Re: Reduce canvas size non-destructively

Post by Bird »

Thanks. No, the PNG was intentional there. Ideally, I want to input a PNG.

I also tried:

magick in.png -resize 500x out.psd
magick out.psd -gravity center -extent 500x500 out2.psd

and the same for tiff and xcf outputs.

I just want to be able to produce a file where the image information is larger than the canvas size. It seems not possible with IM.

-crop works but the center command is not honored and I also have to merge layers every time I open the output file since crop splits the image into separate layers.
magick in.png -resize 500x out.psd
magick out.psd -gravity center -crop 500x500 out2.psd

Bird
Posts: 5
Joined: 2020-03-26T11:38:33-07:00
Authentication code: 1152

Re: Reduce canvas size non-destructively

Post by Bird »

Maybe ImageMagick has a different definition of "canvas size" than Photoshop or GIMP.

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

Re: Reduce canvas size non-destructively

Post by snibgo »

Bird wrote:I just want to be able to produce a file where the image information is larger than the canvas size. It seems not possible with IM.
In ImageMagick terms, that is easy:

Code: Select all

magick toes.png -page 30x40+10+20 x.png

magick x.png info:
x.png PNG 267x233 30x40+10+20 16-bit sRGB 320296B 0.031u 0:00.035
x.png has a 267x233 image on a 30x40 canvas. The image is entirely there; the canvas size is just metadata.

I don't know if this does what you want in a psd file.
snibgo's IM pages: im.snibgo.com

Bird
Posts: 5
Joined: 2020-03-26T11:38:33-07:00
Authentication code: 1152

Re: Reduce canvas size non-destructively

Post by Bird »

Sadly, the offset has an effect, but not the page size.

This is the manual operation I'm trying to reproduce:
Image

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

Re: Reduce canvas size non-destructively

Post by snibgo »

PNG files have metadata for canvas size. IM reads and writes these. Gimp ignores them when reading, and won't write to them.
snibgo's IM pages: im.snibgo.com

Post Reply