Convert tall image into a small with effect

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
semptrion
Posts: 1
Joined: 2013-10-23T20:34:21-07:00
Authentication code: 6789

Convert tall image into a small with effect

Post by semptrion »

Hi, I have a tall image and I need to convert into a small copyng the top and the base and putting an effect of break image, preserving top and bottom of image.
(Sorry for my English... but an image is like a thousand of words)
Image
Thanks in advance
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert tall image into a small with effect

Post by fmw42 »

You need to do something like:

1) crop the top and bottom parts (-crop)
2) make a mask with the jagged outline on the top and another for the bottom (-draw)
3) composite each mask with the image with a transparent background (-compose ... -composite)
4) add shadows and possibly transparent borders (-shadow, -splice)
5) append the images (-append)

variations of order and other commands may produce the same kind of results.

see
http://www.imagemagick.org/script/comma ... ptions.php
http://www.imagemagick.org/Usage/


Please identify your version of IM and platform.

If you need further help, please supply a separate image for the input (not a combination of the two in one image)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert tall image into a small with effect

Post by snibgo »

It's an interesting example of combining a number of processes towards a single effect. Here's a Windows script that follows fmw42's steps, though not exactly. It creates sample.png, but this might be a page scan or whatever, then applies the processes, resulting in cutout_shad.png. All the convert commands could be combined into one, without all the intermediate files.

Code: Select all

%IM%convert -size 1000x6000 gradient:red-blue sample.png


%IM%convert ^
  -size 1000x100 xc: ^
  -draw "path 'M0,50 L333,99 L666,0 L999,50 L999,99 L0,99 Z'" ^
  cutout_mask.png

%IM%convert ^
  sample.png ^
  ( -clone 0 -gravity North -crop 1000x200+0+0 +repage -write cutout_Top.png ) ^
  ( -clone 0 -gravity South -crop 1000x200+0+0 +repage -write cutout_Bottom.png ) ^
  NULL:

%IM%convert ^
  cutout_Bottom.png ^
  ( +clone -fill Black -colorize 100 cutout_mask.png -negate -gravity North -composite ) ^
  -alpha off ^
  -compose CopyOpacity -composite ^
  cutout_Bottom_cut.png

%IM%convert ^
  cutout_Top.png ^
  ( +clone -fill White -colorize 100 cutout_mask.png -gravity South -composite ) ^
  -alpha off ^
  -compose CopyOpacity -composite ^
  cutout_Top_cut.png

%IM%convert ^
  cutout_Top_cut.png ^
  ( cutout_Bottom_cut.png -repage +0+150 ) ^
  -background None -layers Merge ^
  cutout.png

%IM%convert ^
  cutout.png ^
  ( +clone -background Black -shadow 80x2+12+12 ) ^
  -background None ^
  +swap -layers Merge +repage ^
  cutout_shad.png
snibgo's IM pages: im.snibgo.com
Post Reply