need two crops

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
tiroy_
Posts: 3
Joined: 2017-05-12T01:47:09-07:00
Authentication code: 1151

need two crops

Post by tiroy_ »

I am facing similar problem with crop. I on Win7 64bit, IM windows binary (no cygwin)

D:\>magick -version
Version: ImageMagick 7.0.5-5 Q16 x64 2017-04-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 jng jp2 jpeg lcms lqr openexr pa
ngocairo png ps rsvg tiff webp xml zlib

I try to split "high" picture into few parts with offset (that's _important_).

this command outputs 2 images (EAkzgDiagram3-0.png and EAkzgDiagram3-1.png):
D:\img>magick EAkzgDiagram3.png -crop "100x50%" +repage EAkzgDiagram3-%d.png

this command outputs 1 image (the first/upper one EAkzgDiagram3-0.png ONLY):
D:\img>magick EAkzgDiagram3.png -crop "100x50%-50+0" +repage EAkzgDiagram3-%d.png

I expect 2 images with offset :(
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: need two crops

Post by snibgo »

Your problem is different to the OP, so I am splitting it to a new thread.

If you include offsets such as +0+0 or -50+0 you will get one output image.

If you do not include offsets, you will get multiple outputs.

If you want two outputs, as two different crops with offsets, using clone may be easiest. Windows BAT syntax:

Code: Select all

convert ^
  toes.png ^
  ( -clone 0 -gravity north -crop 100x50%%-50+0 +write c1.png ) ^
  ( -clone 0 -gravity south -crop 100x50%%-50+0 +write c2.png ) ^
  NULL:
EDIT: Corrected second output name.
snibgo's IM pages: im.snibgo.com
tiroy_
Posts: 3
Joined: 2017-05-12T01:47:09-07:00
Authentication code: 1151

Re: need two crops

Post by tiroy_ »

Thank you snibgo!

How would I make 3 or more crops with your approach?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: need two crops

Post by snibgo »

(In my command, I intended that the outputs should have different names. I've corrected the above.)

Just repeat the "( -clone...)" lines as many times as you want, with whatever gravity and crop-parameters you want. To reduce memory usage, you don't need to keep each result in memory, so you can "+delete" it.

Code: Select all

convert ^
  toes.png ^
  ( -clone 0 -gravity north -crop 100x33.3%%-50+0 +write c1.png +delete ) ^
  ( -clone 0 -gravity south -crop 100x33.3%%-50+0 +write c2.png +delete ) ^
  ( -clone 0 -gravity center -crop 100x33.3%%-50+0 +write c3.png +delete ) ^
  ( -clone 0 -gravity SouthEast -crop 100x20%%-50+0 +write c4.png +delete ) ^
  ( -clone 0 -gravity south -crop 25x50%%-50+0 +write c5.png +delete ) ^
  NULL:
snibgo's IM pages: im.snibgo.com
tiroy_
Posts: 3
Joined: 2017-05-12T01:47:09-07:00
Authentication code: 1151

Re: need two crops

Post by tiroy_ »

Should this work with ImageMagick 7.0.5-5 ?
I think Windows system tool convert is called.
D:\>convert /?
Converts a FAT volume to NTFS.

CONVERT volume /FS:NTFS [/V] [/CvtArea:filename] [/NoSecurity] [/X]


volume Specifies the drive letter (followed by a colon),
mount point, or volume name.
/FS:NTFS Specifies that the volume will be converted to NTFS.
/V Specifies that Convert will be run in verbose mode.
/CvtArea:filename
Specifies a contiguous file in the root directory
that will be the place holder for NTFS system files.
/NoSecurity Specifies that the security settings on the converted
files and directories allow access by all users.
/X Forces the volume to dismount first if necessary.
All open handles to the volume will not be valid.

On the other hand...
D:\>echo %PATH%
C:\Program Files\ImageMagick-7.0.5-Q16;C:\Program Files (x86)\RSA SecurID Token
Common;C:\ptc\Ora\Client112\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System
32\Wbem;C:\Program Files\TortoiseSVN\bin;C:\WINDOWS\System32\WindowsPowerShell\v
1.0\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: need two crops

Post by snibgo »

Sorry, you are using v7, so use "magick" instead of "convert".
snibgo's IM pages: im.snibgo.com
Post Reply