turn image with borders into full bleed image

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
sparr
Posts: 4
Joined: 2015-01-24T19:04:33-07:00
Authentication code: 6789

turn image with borders into full bleed image

Post by sparr »

I want to "extend" the contents of this image to eliminate the white border, so that when it's printed and cut out the color will go all the way to the final edge regardless of where the cuts are made. Is there a straightforward way to do this?

Image
sparr
Posts: 4
Joined: 2015-01-24T19:04:33-07:00
Authentication code: 6789

Re: turn image with borders into full bleed image

Post by sparr »

I may be willing to crop the image to get rid of the rounded corners, if that's helpful.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: turn image with borders into full bleed image

Post by fmw42 »

This is a unix syntax solution. Note I have to shave off 10 pixel on each side after trimming to remove the rounded corners

Code: Select all

size=`convert nfuqC0r.png -format "%wx%h" info:`
convert nfuqC0r.png -trim tmp.png 
xoff=`convert tmp1.png -format "%X" info: | sed 's/+//g'`
yoff=`convert tmp1.png -format "%Y" info: | sed 's/+//g'`
xoff=$((xoff-10))
yoff=$((yoff-10))
vcoords="$size-$xoff-$yoff"
echo $vcoords
convert tmp.png +repage -shave 10x10 \
-define distort:viewport=$vcoords +distort SRT 0 +repage result.png
rm -f tmp.png
Image


see
http://www.imagemagick.org/script/escape.php
http://www.imagemagick.org/Usage/distor ... t_viewport


This also works by trimming and making the corners transparent. Then measuring the color at the rounded corners and using -sparse-color voronoi to fill out the whole image with those colors. Then overlay the the transparent image over the result of the voronoi processed image. This way no shaving is needed.

Code: Select all

size=`convert nfuqC0r.png -format "%wx%h" info:`
convert nfuqC0r.png -trim tmp.png 
xoff=`convert tmp1.png -format "%X" info: | sed 's/+//g'`
yoff=`convert tmp1.png -format "%Y" info: | sed 's/+//g'`
vcoords="$size-$xoff-$yoff"
echo $vcoords
convert tmp.png -transparent white +repage \( -clone 0 -alpha off -sparse-color Voronoi \
"9,9 rgb(255,8,8)  969,9 rgb(255,255,8)  969,669 rgb(255,255,248)  9,669 rgb(255,248,248)" \) \
+swap -compose over -composite \
-define distort:viewport=${size}-$xoff-$yoff +distort SRT 0 +repage result2.png
rm -f tmp.png
See
http://www.imagemagick.org/Usage/canvas/#voronoi
Post Reply