I was hoping someone might be able to give me some help with the following problem.
I have a few border images, such as the following:
and a large number of images that I need to place inside these borders. I've been using the crop_resized and composite methods of the RMagick library and it works perfectly when the overlay image is larger than the border into which I'm placing it. The trouble I'm having is when I encounter a smaller image, such as the following:
I'd like to know how to resize (shrink) the border image so that the dimensions of the blank center part are similar (or the same) as the smaller image, so then I can just place the smaller image into this blank portion.
I was thinking that I might be able to find the difference between the small image and the blank part of the border image as a percentage, and then shrink the border image by this value. So in this example, the white part of the border image is 577x428 and the smaller image is 288x204, so the difference in size is (204/428)*100 =~ 47.66% (I can either use the x-values or the y-values). But I'm not sure if this is the best way to solve this problem, so I figured I'd see if anyone here has better suggestions. Thanks in advance.
Adam
Shrinking a border image to fit inner image
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Shrinking a border image to fit inner image
Do you want the width of the border to also shrink?
If yes then resize the frame. But I think you want the frame to adjust itself to fit the image.
I suggest you look at the tiled framing methods shown toward the bottom of IM Examples, Thumbnails, Framing using Edge Images
All that you need do then is extract a top and bottom edge image from your original frame image.
Also look at the script set frame_edges.tar.gz or a similar but slightly different script from Fred's ImageMagick Scripts picframe.
As for the internal 'cardboard spacing' that is easier to generate using -border and -frame separately to the frame tiles.
WARNING: what the detail and shadow effects on the frame, it is VERY easy to get wrong, especially with frames containing a lot of details.
If yes then resize the frame. But I think you want the frame to adjust itself to fit the image.
I suggest you look at the tiled framing methods shown toward the bottom of IM Examples, Thumbnails, Framing using Edge Images
All that you need do then is extract a top and bottom edge image from your original frame image.
Also look at the script set frame_edges.tar.gz or a similar but slightly different script from Fred's ImageMagick Scripts picframe.
As for the internal 'cardboard spacing' that is easier to generate using -border and -frame separately to the frame tiles.
WARNING: what the detail and shadow effects on the frame, it is VERY easy to get wrong, especially with frames containing a lot of details.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Shrinking a border image to fit inner image
Thanks for your reply Anthony, very helpful! I ended up following the steps on the Framing using Edge Images link you posted and have managed to generate complex frames with 45 degree angle joins. Thanks again!anthony wrote:Do you want the width of the border to also shrink?
If yes then resize the frame. But I think you want the frame to adjust itself to fit the image.
I suggest you look at the tiled framing methods shown toward the bottom of IM Examples, Thumbnails, Framing using Edge Images
All that you need do then is extract a top and bottom edge image from your original frame image.
Also look at the script set frame_edges.tar.gz or a similar but slightly different script from Fred's ImageMagick Scripts picframe.
As for the internal 'cardboard spacing' that is easier to generate using -border and -frame separately to the frame tiles.
WARNING: what the detail and shadow effects on the frame, it is VERY easy to get wrong, especially with frames containing a lot of details.