Converting PSD files with undeleted cropped pixels

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
secondplace
Posts: 5
Joined: 2016-05-17T21:20:00-07:00
Authentication code: 1151

Converting PSD files with undeleted cropped pixels

Post by secondplace »

hi,

i'm trying to batch convert several PSD files. apparently the have been cropped inside photoshop without the 'delete cropped pixels' function.
When i run something along the lines of this:

Code: Select all

convert.exe *.psd -resize 1000x1000 *.jpg
the output will look the following:
Image

how to tell imagemagick to ignore the undeleted cropped pixels?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting PSD files with undeleted cropped pixels

Post by snibgo »

I suppose Photoshop doesn't change the image, but merely writes some metadata about the crop. I don't know if IM can read that metadata. If you put up a sample cropped PSD, someone might take a look.
snibgo's IM pages: im.snibgo.com
secondplace
Posts: 5
Joined: 2016-05-17T21:20:00-07:00
Authentication code: 1151

Re: Converting PSD files with undeleted cropped pixels

Post by secondplace »

here is a sample (270kb) saved from cs6:

edit: sample removed, i uploaded a new version in the post bellow.
Last edited by secondplace on 2016-05-18T03:51:01-07:00, edited 2 times in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting PSD files with undeleted cropped pixels

Post by snibgo »

Exiftool says "Has crop: false".

IM's identify says there are two identical images, both 357x259. They look like the image on the left in the OP.
snibgo's IM pages: im.snibgo.com
secondplace
Posts: 5
Joined: 2016-05-17T21:20:00-07:00
Authentication code: 1151

Re: Converting PSD files with undeleted cropped pixels

Post by secondplace »

first of all, i messed up the sample. sry for that *selfslap*

i've done some more testing and i get different results depending on how i process the images.

if i process a single image that is (240dpi) i get two output files, name-0.jpg and name-1.jpg.'-0' being correct cropped and '-1' is with the hidden area.
if i convert the image to 72dpi first in photoshop i still get two output files but both are cropped correct.
now with batch convert i get only one output which is the wrong cropped one. i assume the second written image overwrites the first one which would have been correct.

here is my batch script:

Code: Select all

convert.exe *.psd -resize 1000x1000 -quality 80% -density 72x72 -set filename:f %t_tmb %[filename:f].jpg
here the for the single image:

Code: Select all

convert.exe name.psd -resize 1000x1000 -quality 80% -density 72x72 name.jpg
it also seems that on smaller images the it saves out both images with the correct crop so i guess it also has to do with the image size. so here a full test image (80mb): *edit* removed, solution found below!

is it possible to tell imagemagick to write only the correct cropped one which would be the first of the two?
Last edited by secondplace on 2016-05-18T21:58:41-07:00, edited 2 times in total.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting PSD files with undeleted cropped pixels

Post by snibgo »

Append [n] to the input file, where n is the number of the required image in the file, starting from zero. Eg:

Code: Select all

convert.exe name.psd[0] -resize 1000x1000 -quality 80% -density 72x72 name.jpg
snibgo's IM pages: im.snibgo.com
secondplace
Posts: 5
Joined: 2016-05-17T21:20:00-07:00
Authentication code: 1151

Re: Converting PSD files with undeleted cropped pixels

Post by secondplace »

thank you very much for the solution snibgo :D

(some other thing i just noticed. it works fine with jpg. when i try to batch output tiff files it only writes the first image it finds in a folder.)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting PSD files with undeleted cropped pixels

Post by fmw42 »

What is your exact command line for the above problem with tif. JPD does not allow multilayers, but TIF and PSD do. The first layer of the PSD is the flattened layer, but each layer of TIF is a different layer. Can you post an example tif where this fails? What is that you want for the output from TIF files?
secondplace
Posts: 5
Joined: 2016-05-17T21:20:00-07:00
Authentication code: 1151

Re: Converting PSD files with undeleted cropped pixels

Post by secondplace »

the command line is about the same as the one i posted except with tif as output:

Code: Select all

convert.exe *.psd[0] -resize 1000x1000 -density 72x72 -set filename:f %t_tmb %[filename:f].tif
i cannot upload multiple 100mb+ psd files from here since i'm currently on prepay in a third world country.
but download my previous sample here and try to multiply it, that should give you the same result:
http://3dart.tv/beta/imagemagick_convertsample_v2.rar (83mb)

hope that helps
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting PSD files with undeleted cropped pixels

Post by snibgo »

These are large images. A "convert *.psd" will attempt to read all the images into memory at the same time.

A better strategy is either to use "mogrify", or to put the convert inside a for-loop, so each convert reads only one file.
snibgo's IM pages: im.snibgo.com
Post Reply