In our system we allow customers to upload "border images in .png formats" like below.
Please find the images of three borders which we allow customers to upload in our system.
http://f.cl.ly/items/0G1l3Z1c2A0w1r290C3I/keyline.png
http://f.cl.ly/items/0X3u3e3F0D1s1v3g2u0K/black.png
http://f.cl.ly/items/3C0C1G3S253J3p3y3X2M/art.png
So what i am trying to do is, trying to insert the below image in the above three borders.
http://f.cl.ly/items/0g0p0x1V1L083E3E0745/1.jpg
And you guys gave me a command for that, First i should convert the image to the desired pixels and next i have to convert the border to the desired pixels and composite both border and image to the center ,
" convert \( 1.jpg -resize "500x500" -write 1k.jpg \) \( WH.png -resize "500x500" -write WH1.png \) -gravity center -composite fi.jpg"
http://f.cl.ly/items/0g0p0x1V1L083E3E0745/1.jpg
http://f.cl.ly/items/0m3b1E3B0r1B3F3D2S1r/1k.jpg
http://f.cl.ly/items/1Y2d2y2B1G291J1p2q0B/WH.png
http://f.cl.ly/items/2M2q2S2a0i1Q0p0G2q3H/WH1.png
http://f.cl.ly/items/253Q2F3u3P1R1Q44143J/fi.jpg
So in the final fi.jpg there is some portion of the image at the 4 corners is covered by the border WH1.png.
But i am expecting the final image should be surrounded by border but not border on the image.
Problem while applying Borders.
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Problem while applying Borders.
Last edited by helloworld on 2013-06-23T09:01:45-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problem while applying Borders.
Windows script:
Code: Select all
convert ^
art.png -resize 237x238%% ^
1.jpg ^
-gravity center -composite ^
fi2.jpg
snibgo's IM pages: im.snibgo.com
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem while applying Borders.
I am not familiar with Windows script, Can you tell the Bash script or Linux command?
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem while applying Borders.
I have the border X Y W and H values like this {"x":40,"y":26,"w":519,"h":347}
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problem while applying Borders.
Code: Select all
convert \
art.png -resize 237x238% \
1.jpg \
-gravity center -composite \
fi2.jpg
snibgo's IM pages: im.snibgo.com
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem while applying Borders.
I did not understand this, But i can explain you more clearly on what i exactly want.
I am looking for a Linux Command where i can fit my own border to an image. Right now, we have 5 predefined borders in our system like Art, Gallery, Black, Reverse Keyline, White and Keyline. below are those links for those border images.
http://f.cl.ly/items/0g0p0x1V1L083E3E0745/1.jpg
You guys already gave me a command for this, what you said is first re-size the Image and then re-size the Border and then place image at the -gravity center -composite .
But if i do in this way, I am missing four sides of the image. I mean border is coming on the top the image and covering four sides of the image but what i want is, image should be surrounded by the border but not border on image.
I am looking for a Linux Command where i can fit my own border to an image. Right now, we have 5 predefined borders in our system like Art, Gallery, Black, Reverse Keyline, White and Keyline. below are those links for those border images.
- http://f.cl.ly/items/0G1l3Z1c2A0w1r290C3I/keyline.png
http://f.cl.ly/items/0X3u3e3F0D1s1v3g2u0K/black.png
http://f.cl.ly/items/3C0C1G3S253J3p3y3X2M/art.png
http://f.cl.ly/items/1C1w07181g0a0B3X1z ... eyline.png
http://f.cl.ly/items/3H3h1B3e1O1X3o1N3X2q/white.png
http://f.cl.ly/items/101d1p2x3v3R3C0b2e3q/gallery.png
http://f.cl.ly/items/0g0p0x1V1L083E3E0745/1.jpg
You guys already gave me a command for this, what you said is first re-size the Image and then re-size the Border and then place image at the -gravity center -composite .
But if i do in this way, I am missing four sides of the image. I mean border is coming on the top the image and covering four sides of the image but what i want is, image should be surrounded by the border but not border on image.
Re: Problem while applying Borders.
You must resize the image to the dimensions of the hole in the border instead of to the full dimensions of the border. You will need to keep track of the inside dimensions of your 5 borders in order to do that.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Problem while applying Borders.
Instead of resizing the image (1.jpg) to fit the border (art.png), my command resizes the border to refit the image.
I calculated that the border width should be increased by 237%, and height by 238%. How did I calculate this?
art.png is 600 pixels width, with left and right margins 47 pixels. It is 400 high, with top and bottom margins 32.
600-47-47 = 506
400-32-32 = 336
So the inside of the frame is 506x336. We need this to match 1.jpg, which is 1200x800.
1200/506 = 2.371541501976285, 237%
800/336 = 2.380952380952381, 238%.
I calculated that the border width should be increased by 237%, and height by 238%. How did I calculate this?
art.png is 600 pixels width, with left and right margins 47 pixels. It is 400 high, with top and bottom margins 32.
600-47-47 = 506
400-32-32 = 336
So the inside of the frame is 506x336. We need this to match 1.jpg, which is 1200x800.
1200/506 = 2.371541501976285, 237%
800/336 = 2.380952380952381, 238%.
snibgo's IM pages: im.snibgo.com
-
- Posts: 69
- Joined: 2013-05-22T09:42:33-07:00
- Authentication code: 6789
Re: Problem while applying Borders.
I will try and get back to you if i have any issues.