Page 1 of 1

PAID: Looking for help configuring a script.

Posted: 2018-04-10T08:04:28-07:00
by patrickm
Looking for help configuring a script. Had it working but now sometimes the
clipping paths don't clip properly. Doesn't happen on every image with a
clipping path. When it goes wrong, it might clip the correct shape but be misaligned by a few pixels. Also, it might clip the correct shape but clip a few pixels too large, leaving part of the background.

Currently, the script processes EPS, TIFF and PSDs. The TIFFs and PSDs have
clipping paths with a particular name. If the image has a clipping path, it will
clip the image and place it on a white background. It then creates multiple
images (75x75, 150x150, 300x300 and 600x600). It will also do some sharpening
and compression.

We cannot identify a pattern with respect to image type, dimension, or file size. It seems pretty random.

Re: Looking for help configuring a script.

Posted: 2018-04-10T09:40:37-07:00
by fmw42
Is this Paid consulting? If not, then this topic should be moved to the User's forum.

What is your IM version and platform and scripting software?

Can you post an example image that does not work?

Re: PAID: Looking for help configuring a script.

Posted: 2018-04-11T06:23:05-07:00
by patrickm
This is paid consulting. I'll gather the info you requested and post it as soon as I have it. Thanks.

Re: PAID: Looking for help configuring a script.

Posted: 2018-04-13T09:23:48-07:00
by patrickm
Here's the info you were looking for. For the images, I've zipped up a collection of the original images (some good/some bad) so you can run it thru and see what I'm talking about.

VERSION INFO:
Version: ImageMagick 7.0.7-24 Q8 x64 2018-02-25 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr
openexr pangocairo png ps raw rsvg tiff webp xml zlib

Machine it's running on is a Windows Server 12 64bit

EXAMPLE OF SCRIPT:
convert -density 400x400 -profile "C:\Step_Assets\Profile\cmyk.icc" -profile "C:\Step_Assets\Profile\sRGB_profile.icc" "C:\Users\timg\Desktop\Testing Imagemagick\original\852067A-2.tif" -flatten -bordercolor Black -border 5x5 -alpha transparent -clip-path "silo" -alpha opaque -density 72x72 +clip -trim -strip ( +clone -resize 75x75 -gravity center -extent 75x75 +repage -sampling-factor 4:2:2 -sharpen 2 -quality 100 -write "C:\Users\timg\Desktop\Testing Imagemagick\converted\852067A-2_t.jpg" +delete ) ( +clone -resize 150x150 -gravity center -extent 150x150 +repage -sampling-factor 4:2:2 -sharpen 4 -quality 96 -write "C:\Users\timg\Desktop\Testing Imagemagick\converted\852067A-2_m.jpg" +delete ) ( +clone -resize 300x300 -gravity center -extent 300x300 +repage -sampling-factor 4:2:2 -sharpen 3 -quality 96 -write "C:\Users\timg\Desktop\Testing Imagemagick\converted\852067A-2_f.jpg" +delete ) -resize 600x600 -gravity center -extent 600x600 +repage -sampling-factor 4:2:2 -sharpen 2 -quality 96 "C:\Users\timg\Desktop\Testing Imagemagick\converted\852067A-2_d.jpg"

TEST FILES:
http://nimmot.net/imagemagick/consult.zip

Thanks and I look forward to hearing from you.

Re: PAID: Looking for help configuring a script.

Posted: 2018-04-13T11:45:04-07:00
by fmw42
You command is rather long and hard to read. Can you do a simpler command and make it fail? For example without writing multiple output image? Does it help to use +write rather than -write? Do all your files have clip paths? Are they all CMY input. If not, the using both CMYK and SRGB profiles is not a good idea.

Perhaps you should test each file for colorspace and clipping paths and script a change of command depending upon what you find.

You probably should add +repage after -trim.

Re: PAID: Looking for help configuring a script.

Posted: 2018-04-13T12:41:53-07:00
by fmw42
I am not on Windows (I use a Mac) so this is a unix style script to run through all your images that I put into folder test1 and wrote the jpg output to folder test2. They all seem to work fine as a simple command without all the resizes using IM 6.9.9.40 Q16 Mac OSX or IM 7.0.7.24 Q16 Mac OSX with ghostscript 9.21, libtiff 4.0.9 and libjpeg 9. I also wrote out all the filenames, colorspaces and profiles to show you how you could obtain them if you want to test for that. Note that I changed your command from -clip-path "silo" to just -clip. I added +repage after the -trim, though it is not necessary from jpg output. I also used a different CMYK profile. Also note that proper syntax needs the -profile commands to follow reading the image. IM 6 is forgiving, but IM 7 is not. However, when it does not find a clip path it fails to produce and output.

Code: Select all

cd
cd desktop/test1
list=`ls`
echo $list
for img in $list; do

name=`magick -quiet -ping "$img[0]" -format "%t" info:`
colorspace=`magick -quiet -ping "$img[0]" -format "%[colorspace]" info:`
profiles=`magick -quiet -ping "$img[0]" -format "%[profile:icc]" info:`
echo "$img $colorspace $profiles"
echo ""

magick -quiet -density 400x400 \
"$img[0]" \
-profile /Users/fred/images/profiles/USWebCoatedSwop.icc \
-profile /Users/fred/images/profiles/sRGB.icc \
-flatten \
-bordercolor Black -border 5x5 \
-alpha transparent \
-clip \
-alpha opaque \
+clip \
-strip \
-trim +repage \
-density 72x72 \
../test2/${name}.jpg

done

Here is the terminal listing.

Code: Select all

1224272A.tif CMYK 
1224272A.tif CMYK 

1255344.eps CMYK 

magick: no clip path defined '1255344.eps': Undefined error: 0 @ error/image.c/ClipImagePath/734.
1372669A.tif CMYK U.S. Web Coated (SWOP) v2

1375107A.tif CMYK U.S. Web Coated (SWOP) v2

1375962A.tif CMYK U.S. Web Coated (SWOP) v2

magick: no clip path defined '1375962A.tif': Undefined error: 0 @ error/image.c/ClipImagePath/734.
1376567A.tif CMYK U.S. Web Coated (SWOP) v2

1376632A.tif CMYK U.S. Web Coated (SWOP) v2

1376705A.tif CMYK 

1376780A.tif CMYK U.S. Web Coated (SWOP) v2

852067A-2.tif CMYK 

852067A.tif CMYK 

H130580S.eps CMYK 

magick: no clip path defined 'H130580S.eps': Undefined error: 0 @ error/image.c/ClipImagePath/734.
X1221535A.tif CMYK U.S. Web Coated (SWOP) v2

X1221536A.tif CMYK U.S. Web Coated (SWOP) v2

X802780J.tif CMYK U.S. Web Coated (SWOP) v2

So you should test on the existence of the clip path and if it does not exist, then use a different command.

Also you might check your versions of Ghostscript, libtiff and libjpeg and if not current, then upgrade.

Re: PAID: Looking for help configuring a script.

Posted: 2018-04-16T13:05:52-07:00
by patrickm
Thanks for getting back fmw42. I'm sending you a PM to discuss.