Page 1 of 1

Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-24T03:20:00-07:00
by bartdenolf
Hello,

At this moment we use Photoshop actions to do our routine tasks. But now we want to use Imagemagick to improve speed and eliminate a lot of problems. Our version is 7.0.6-0 q16 x86_64

One of the tasks is a simple trim of transparent pixels. The files are all psd files with a clipping mask.
When I do:

Code: Select all

convert test.psd -trim +repage test2.psd
I get a nicelly trimmed image, but my clipping path is distorted. The clipping path looks like it has been scaled doing the trim and so doesn't correspond with the image.
What is the solution?

Thanks
Bart

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-24T04:57:16-07:00
by Bonzo
You will probably need to post an example image somewhere for other users to test. It does not have to be an actual image you use but anything created using the same method.

Also although convert can work in V7 you should be using magick instead.

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-24T05:24:00-07:00
by bartdenolf
I've been checking my other flows and I've see that the problem keeps reoccurring even if I do a simple "-scale".

You can download a test file and the result at https://www.dropbox.com/sh/8docgtwxji75 ... Ub3ma?dl=0

Thanks
Bart

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-24T09:34:52-07:00
by fmw42
I believe that your clip path is intentional rough at the top so as to represent being torn open. This is what I get with IM 6.9.9.9 Q16 Mac OSX Sierra

Code: Select all

convert test.psd[0] -trim +repage calbani6.png
Image

Using IM 7.0.6.9 Q16 HDRI, I get the same result

Code: Select all

magick test.psd[0] -trim +repage calbani7.png
Image

If you do not get similar results, then try upgrading your IM 7.

Sorry, I do not have Photoshop to check or output to PSD.

Imagemagick does not know how to deal with group layers and adjustment layers. So just use the flattened layer [0] as I did above. See if that works.

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-24T09:42:38-07:00
by fmw42
P.S. You could try the -define psd:additional-info=all|selective. See http://www.imagemagick.org/script/comma ... php#define

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-25T00:32:49-07:00
by bartdenolf
Hello,

Thanks for the reply. But unfortunately both solutions didn't do the trick. In both of the solutions my Clipping Path is scaled and doesn't fit the outlines of the product.
Unfortunately I can not flatten or remove the path because the designers still need the Clipping path in Indesign. So I have to find a solution to trim the image and not distort the Clipping Path.
I remember someone having a similar problem and as far as I can remember eventually the solution was copying the path temporarily to an other image doing a trim and placing the path back. Is this possible or am I imagining this? :)

Thanks
Bart

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-25T09:32:22-07:00
by fmw42
I believe that Imagemagick can extract the clip path, though I am not sure the commands. But I do not know if it can put it back. You may need to use EXIFTOOL for one or both processes. Perhaps some one else on the forum knows more about that than I. I do not use Photoshop that often and do not have a copy on my current computer. But note, that, once you trim the image, the clip path needs to change for the trim offset. So if you extract the trim path, you would likely need to modify it for the trim offset values so that it properly corresponds to the trimmed image.

You could try GIMP and if that works, write a GIMP script.

But did my process above work properly when output as PNG? Are you getting more jagged outline than I did?

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-28T00:29:38-07:00
by bartdenolf
Thanks for the reply,

I work in a photo studio of a big firm and so we have guidelines of what the output of our files must be. All files must be PSD, transparant and must contain a clipping path. The photo's are used for print and for web.
At this moment we are using Enfocus Switch, an automation tool, together with Photoshop. But Photoshop is struggling to keep up, because it never was build for automation. So Enfocus recommended to use Imagemagick instead of Photoshop. But now that I'm starting to convert all my flow's I'm having troubles because I have the feeling Imagemagick isn't really build for PSD and Clipping paths.

Bart

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-08-28T17:10:13-07:00
by fmw42
I went back to my old Mac system that has Photoshop PS (very old) and these commands work fine and the image look fine and the resulting resized images have clip paths. Using IM 6.9.9.10 Q16 and IM 7.0.6.10 Q16.

Code: Select all

convert test.pds -resize 50% test_r5_im6.psd

magick test.pds -resize 50% test_r5_im7.psd
The resulting psd files open fine in PS CS, look proper and do include clipping paths. I cannot say if the clip paths are correct or not. But I assume that since the images look fine with regard to the transparency, then the clip paths are correct.

Filling the paths with black matches the outline of the image with it transparent background. So I assume it is working fine.

If it does not work for you in your version of IM 7, then upgrade to the latest version and let us know if that works. What is your platform/OS? Please always provide your IM version and platform when posting questions.

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-09-18T07:33:10-07:00
by bartdenolf
Hello everyone,

The resize isn't a problem anymore, if I don't forget to include the layers. My biggest problem is trimming the excess pixels and not distorting the Photoshop clipping path.
But the more I'm investigating it I see there is probably no solution, because ImageMagick wasn't made to work with clipping paths.

Does anyone know a script that can do trimming without using ImageMagick?

Bart

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-09-18T09:37:48-07:00
by fmw42
You could write a Photoshop action script.

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2017-09-26T06:56:32-07:00
by bartdenolf
Hello fmw42,

The problem is we are searching for a solution to replace Photoshop. Now we use is it, but Photoshop isn't a server side software and starts getting sluggish if you leave it open 24/7.

Greetings
Bart

Re: Trim transparant pixels from psd with clipping mask problem

Posted: 2019-07-23T10:23:29-07:00
by mihu12
Hi, there

Hi, Is there any solution to this clipping path associated with trim? Face a similar problem that when the picture is trimmed, the ClippingPath is no longer correct.

Alternatively, I've been looking for a way to make the trim function in GIMP. Unfortunately, GIMP deactivates the "ClippingPath" and converts it into a normal working path. But i need the ClippingPath

Is it possible via ImageMagick to enable Path 1 again as ClippingPath?

Thank you for your help