Multicrop with CMYK tiff

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Post Reply
oniben
Posts: 3
Joined: 2020-03-25T13:38:38-07:00
Authentication code: 1152

Multicrop with CMYK tiff

Post by oniben »

Hi all,

I'm attempting to use the multicrop script on a TIF. It fails with this error message:

Code: Select all

convert: geometry does not contain image `./multicrop_3_26802.mpc' @ warning/attribute.c/GetImageBoundingBox/507.
/usr/local/bin/multicrop: line 599: 5250x7200: value too great for base (error token is "5250x7200")
I get the same error message after converting the file to any other CMYK format, but I get successful results when I convert it to an RGB format first.

When I uncomment some of the echos in the script I get this result message:

Code: Select all

525 720 1 cmyka(0,255,255,2.92481e-07,1)
It seems like there is possibly some problem with reading the black value.

Any insight would be very appreciated!

My Imagemagick version info:

Code: Select all

Version: ImageMagick 7.0.10-0 Q16 x86_64 2020-03-08 https://imagemagick.org
Copyright: © 1999-2020 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(3.1) 
Delegates (built-in): bzlib freetype heic jng jp2 jpeg lcms ltdl lzma openexr png tiff webp xml zlib


Input File info:

Code: Select all

identify -verbose original.tif 
Image: original.tif
  Format: TIFF (Tagged Image File Format)
  Mime type: image/tiff
  Class: DirectClass
  Geometry: 5250x7200+0+0
  Resolution: 600x600
  Print size: 8.75x12
  Units: PixelsPerInch
  Colorspace: CMYK
  Type: ColorSeparationAlpha
  Base type: ColorSeparation
  Endianess: LSB
  Depth: 8-bit
  Channel depth:
    Cyan: 8-bit
    Magenta: 8-bit
    Yellow: 8-bit
    Black: 8-bit
    Alpha: 1-bit
  Channel statistics:
    Pixels: 37800000
    Cyan:
      min: 0  (0)
      max: 228 (0.894118)
      mean: 67.3378 (0.26407)
      standard deviation: 58.1842 (0.228173)
      kurtosis: -0.668163
      skewness: 0.507256
      entropy: 0.668009
    Magenta:
      min: 0  (0)
      max: 255 (1)
      mean: 105.49 (0.413688)
      standard deviation: 76.912 (0.301616)
      kurtosis: -1.47513
      skewness: -0.256605
      entropy: 0.612763
    Yellow:
      min: 0  (0)
      max: 255 (1)
      mean: 147.173 (0.57715)
      standard deviation: 96.5857 (0.378767)
      kurtosis: -1.2043
      skewness: -0.684766
      entropy: 0.60311
    Black:
      min: 0  (0)
      max: 217 (0.85098)
      mean: 59.6922 (0.234087)
      standard deviation: 71.748 (0.281365)
      kurtosis: -1.00575
      skewness: 0.74408
      entropy: 0.600562
    Alpha:
      min: 255  (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: nan (nan)
      kurtosis: 1.43009e+57
      skewness: 3.63595e+40
      entropy: 0
  Image statistics:
    Overall:
      min: 0  (0)
      max: 255 (1)
      mean: 126.939 (0.497799)
      standard deviation: nan (nan)
      kurtosis: -1.53907
      skewness: -0.0481444
      entropy: 0.496889
  Total ink density: 289.02%
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Matte color: grey74
  Background color: white
  Border color: srgb(223,223,223)
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 5250x7200+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: LZW
  Orientation: TopLeft
  Profiles:
    Profile-8bim: 8936 bytes
    Profile-icc: 557168 bytes
    Profile-xmp: 16224 bytes
  Properties:
    date:create: 2020-03-25T20:40:30+00:00
    date:modify: 2019-04-16T00:02:00+00:00
    dc:format: image/tiff
    exif:PixelXDimension: 5250
    exif:PixelYDimension: 7200
    icc:copyright: Copyright 2000 Adobe Systems, Inc.
    icc:description: U.S. Web Coated (SWOP) v2
    photoshop:ColorMode: 4
    photoshop:ICCProfile: U.S. Web Coated (SWOP) v2
    signature: 04cad517b854fbd4c20280617977169d95bd1952c9470540df6438b87f531b8d
    tiff:alpha: unspecified
    tiff:endian: lsb
    tiff:photometric: separated
    tiff:rows-per-strip: 9
    tiff:software: Adobe Photoshop CC 2014 (Macintosh)
    tiff:timestamp: 2019:04:12 09:46:43
    xmp:CreateDate: 2018-03-12T13:38:47+13:00
    xmp:CreatorTool: Adobe Photoshop CC 2014 (Macintosh)
    xmp:MetadataDate: 2019-04-12T09:46:43+12:00
    xmp:ModifyDate: 2019-04-12T09:46:43+12:00
    xmpMM:DerivedFrom: xmp.did:33a3d368-af1e-44f9-9859-a606fbce6a57
    xmpMM:DocumentID: adobe:docid:photoshop:ad132c8c-9d31-117c-bff1-8129ec14e7d2
    xmpMM:InstanceID: xmp.iid:8f8ee791-93e0-4d6e-a6da-ed7f7f5e597d
    xmpMM:OriginalDocumentID: xmp.did:33a3d368-af1e-44f9-9859-a606fbce6a57
  Artifacts:
    verbose: true
  Tainted: False
  Filesize: 30.9749MiB
  Number pixels: 37800000
  Pixels per second: 13.1728MP
  User time: 11.570u
  Elapsed time: 0:03.869
  Version: ImageMagick 7.0.10-0 Q16 x86_64 2020-03-08 https://imagemagick.org
identify: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/1036.

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

Re: Multicrop with CMYK tiff

Post by fmw42 »

The script is not designed to process CMYK images. Please convert your image to sRGB and then try again.

oniben
Posts: 3
Joined: 2020-03-25T13:38:38-07:00
Authentication code: 1152

Re: Multicrop with CMYK tiff

Post by oniben »

Thanks for the reply! In this case I really need to keep them cmyk, so I'll look into other solutions, but I really appreciate your quick answer.

Cheers!

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

Re: Multicrop with CMYK tiff

Post by fmw42 »

You can convert to RGB, process, then convert back to CMYK.

Perhaps you can do your processing in CMYK with -connected-components, which is what I use in my script. All you need to do is convert your image to binary where the images are white and the background is black. Then process that image with my script or with -connected-components to find the bounding boxes of the regions. My script will list them. Then uses those bounding boxes to crop your original CMYK image. If you need help doing that, post an example CMYK image.

oniben
Posts: 3
Joined: 2020-03-25T13:38:38-07:00
Authentication code: 1152

Re: Multicrop with CMYK tiff

Post by oniben »

Thanks!

I was able to make multcrop2 work by changing the suffix of tmpA1 from mpc to png. Thus, it makes the masks using the png file.

Then, when it crops I have it set $img to the original $infile rather than the temp file. Of course, this assumes no resizing, but for my purposes it works well. Anything I'm missing or things I should be aware of with this approach?

I thought about the method you suggested, but it was a bit out of my depth.

Again, thanks a bunch for your help!

Post Reply