-
-
Save iCreateJB/4979468 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create Image Mask ( circle.png ) | |
# convert -size 168x168 xc: -transparent white -fill blue -draw 'circle 84,84 24,24' circle.png | |
# System command. | |
# convert original.image.png -resize '168x168^' -gravity center -crop '168x168+0+0' original.resize.png; | |
# convert -size 168x168 xc: -fill original.resize.png -draw 'circle 85,80 25,25' circle.png | |
# Leaves the image offset but centered. | |
# image = Magick::Image.read('original.image.png').first | |
# image.resize_to_fill(168,168,'center') | |
# image.write 'original.resize.png' | |
# image.destroy! | |
# `convert -size 168x168 xc: -fill original.resize.png -draw 'circle 85,80 25,25' thumbnail.png` | |
@mask = Magick::Image.read('circle.png').first | |
@destination = Magick::Image.read('original.image.png').first | |
@source = Magick::Image.new 168,168 | |
@destination.resize_to_fill!(168,168) | |
@destination = @destination.add_compose_mask(@mask) | |
@result = @destination.composite(@source, Magick::CenterGravity, Magick::OverCompositeOp) | |
@result = @result.add_compose_mask(@mask) | |
@result = @result.blur_image(0,0.25) | |
@result.write 'original.resize.png' | |
@result.destroy! |
Yes, something like this
http://www.imagemagick.org/RMagick/doc/image1.html#add_compose_mask
Created a mask via:
convert -size 168x168 xc: -fill blue -draw 'circle 85,80 25,25' circle.png
Then took the original image as the argument, resized it and placed the mask over it. It seems to have created the desired effect that I was after. Do you see any issues with it?
If that produces what you want I say ship it :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you started here? http://www.imagemagick.org/RMagick/doc/comtasks.html#resizing