How to make reflected Image thumbnails
How to make reflected Image thumbnails
Hi,
I'm a french beginner with ImageMagick and I need your help. I'm trying to make a reflected image like coverflow does in iTunes with your Artwork. You can find a sample of the desired result here http://images.apple.com/ipod/red/images ... 070905.png.
Thanks.
I'm a french beginner with ImageMagick and I need your help. I'm trying to make a reflected image like coverflow does in iTunes with your Artwork. You can find a sample of the desired result here http://images.apple.com/ipod/red/images ... 070905.png.
Thanks.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to make reflected Image thumbnails
The angling requires a perspective distort.
The reflection is easiest done before the distort, by flipping the image over
and applying a transparency gradient, then appending the result to the bottom of the original image.
Basically, try to generate each aspect of the resulting image one piece at a time.
All the techniques are in IM Examples.
The reflection is easiest done before the distort, by flipping the image over
and applying a transparency gradient, then appending the result to the bottom of the original image.
Basically, try to generate each aspect of the resulting image one piece at a time.
All the techniques are in IM Examples.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to make reflected Image thumbnails
I had had the similar thoughts to you Anthony
My code is a mishmash of another example I tried. One thing I had problems with before doing a similar distort is that what ever I tried I could not get the -fx "p{v*w,j}" to work horizontaly I had to turn it vertical to distort it then rotate it back !
As I say the code is a real mess but at least it proves the principle.
My code is a mishmash of another example I tried. One thing I had problems with before doing a similar distort is that what ever I tried I could not get the -fx "p{v*w,j}" to work horizontaly I had to turn it vertical to distort it then rotate it back !
Code: Select all
convert House.jpg -flip temp.jpg
convert -size 300x600 gradient:none-white gradient_fx_linear.png
convert temp.jpg gradient_fx_linear.png -gravity south -composite temp3.jpg
convert House.jpg temp3.jpg -append temp1.jpg
convert temp1.jpg -resize 566x852 -rotate 270 -bordercolor white -border 10x10 src_border2.bmp
convert ../new_imagemagick/original_images/map_p_trapezoidal1.png -resize 566!x852! temp_mask2.png
convert -size 660x500 -background white src_border2.bmp temp_mask2.png -fx "p{v*w,j}" temp2.bmp
convert temp2.bmp -rotate 90 -resize 283!x426! -trim output_reflect.jpg
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to make reflected Image thumbnails
The latest IM has new distort options, as detailed on IM examples
http://www.imagemagick.org/Usage/distorts/#distort
However the coordinate handling is NOT settled at this time and will probably be modified in the next couple of point releases to allow better handling of more than a minimal number of coordinates for possible future use in automatic image registration and panorama photo composites.
Of course I have a stack of research papers with lots of other distorts still to implement too.
http://www.imagemagick.org/Usage/distorts/#distort
However the coordinate handling is NOT settled at this time and will probably be modified in the next couple of point releases to allow better handling of more than a minimal number of coordinates for possible future use in automatic image registration and panorama photo composites.
Of course I have a stack of research papers with lots of other distorts still to implement too.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to make reflected Image thumbnails
You will need to change or generate a the trapezoidal map as well as the fx distortion lookup for horizontal use as well. Otherwise you need to get really fancy with your image lookup by rescaling the i,j coordinates when mapping them from the source image (and its size) to the distortion map image (and a different size).Bonzo wrote:I could not get the -fx "p{v*w,j}" to work horizontaly I had to turn it vertical to distort it then rotate it back !
Also, as you did not give the formula you used to generate the image...
../new_imagemagick/original_images/map_p_trapezoidal1.png
The user currently can't use you script!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to make reflected Image thumbnails
Messing about over lunch I have lost my old image. Here is one using the distort method; is a lot quicker and easer than the previous FX method.
Code: Select all
<?php
// Make an inverted copy of the original
exec("convert ../original_images/House.jpg -flip temp.jpg");
// Make a gradiant - transparent to white
exec("convert -size 300x600 gradient:none-white gradient_fx_linear.png ");
// Put the gradiant over the iverted image
exec("convert temp.jpg gradient_fx_linear.png -gravity south -composite temp3.jpg ");
// Join the two images together
exec("convert ../original_images/House.jpg temp3.jpg -append temp1.jpg");
// Draw the red outline - just to confirm area to distort
exec("convert temp1.jpg -draw 'fill none stroke red polygon 0,0 0,425, 282,425, 282,0' before.jpg ");
// Draw the blue outline to show the distortion
exec("convert temp1.jpg -draw 'fill none stroke blue polygon 0,0 0,425, 282,325, 282,100' after.jpg");
// Carry out the distortion
exec("convert temp1.jpg -matte -background white -virtual-pixel background -distort Perspective '0,0 0,425, 282,425, 282,0, 0,0 0,425, 282,325, 282,100' output_reflect3.jpg");
?>
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to make reflected Image thumbnails
I would just make one small warning. The order of the coordinates in perspective is probably going to change from, the order...
to
sometime the next few IM point releases...
The reason is that I am installing a 'least squares fit' which will allow you to give more than the 4 minimal coordinates you would normally need.
This change is for a number of reasons.
Code: Select all
u1,v1 u2,v2 u3,v3 u4,v4 x1,y1 x2,y2 x3,y3 x4,y4
Code: Select all
u1,v1 x1,y1 u2,v2 x2,y2 u3,v3 x3,y3 u4,v4 x4,y4 .....
The reason is that I am installing a 'least squares fit' which will allow you to give more than the 4 minimal coordinates you would normally need.
This change is for a number of reasons.
- it defines links src and destination coordinates that refer to each other
which makes it a lot easier when editing and adjusting the coordinates. - coordinates could also then come from a text file mapping of one coodrinade change per line.
- second it means you can think of the coordinates as any points, not just a
specific quadrilateral. For example a triangle with a center point is another 4 point representation that can be used. - and finally, the main reason... you can use a larger list of automatically determined points (from an image registration). Say 100 or more coordinates!
- This is not just not just for perspectitve but for even higher level polynomial distortions of coordinates, such as barrel/pincussion distortions (corrections), and posibly future spline or triangular mesh warps (think movie transformations!)
- more points of registration also allows your to more exactly define the distortion beyond normal pixel resolution, and the posiblity of automatically deleting 'large error' coordinates.
- Finallly the current (old) method was just something that seemed to be good when I was first proto-typing the perspective transform using -fx. It was never really thought out very well.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to make reflected Image thumbnails
I am trying to do the same thing like original author of this thread.
Look at his image.
Important is that the shadow is not complete image just a part.
I even do not need that image is turned.
I like to create just shadow of the image as if image would be placed on bottom edge on dark (black) reflective table and light position from top and little front.
I did try povray to render such a scene, but I believe imagemagick can do it faster and better.
As I know only base of imagemagick I would really appreciate help.
Especially how do you manage that the reflection of the image reflects only let say bottom 20% of the image.
Thank you very much for your help.
--
richo
http://www.richard-vanek.eu/
Look at his image.
Important is that the shadow is not complete image just a part.
I even do not need that image is turned.
I like to create just shadow of the image as if image would be placed on bottom edge on dark (black) reflective table and light position from top and little front.
I did try povray to render such a scene, but I believe imagemagick can do it faster and better.
As I know only base of imagemagick I would really appreciate help.
Especially how do you manage that the reflection of the image reflects only let say bottom 20% of the image.
Thank you very much for your help.
--
richo
http://www.richard-vanek.eu/
Re: How to make reflected Image thumbnails
Not quite sure what you want exactly; try the code out and display each image for each line as you go. That way you will see what is creating each effect.
I assume you just need this part of the code.
How much of the reflected image is shown depends on the gradiant position. The gradiant can also be rotated and this would give the effect of the light coming from a different angle ?
Change the gradiant to this.
I assume you just need this part of the code.
Code: Select all
<?php
// Make an inverted copy of the original
exec("convert ../original_images/House.jpg -flip temp.jpg");
// Make a gradiant - transparent to white
exec("convert -size 300x600 gradient:none-white gradient_fx_linear.png ");
// Put the gradiant over the iverted image
exec("convert temp.jpg gradient_fx_linear.png -gravity south -composite temp3.jpg ");
// Join the two images together
exec("convert ../original_images/House.jpg temp3.jpg -append temp1.jpg");
How much of the reflected image is shown depends on the gradiant position. The gradiant can also be rotated and this would give the effect of the light coming from a different angle ?
Change the gradiant to this.
Code: Select all
// Make a gradiant - transparent to black
exec("convert -size 300x600 gradient:none-black gradient_fx_linear.png ");
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to make reflected Image thumbnails
The about of the reflection and even how transparent it becomes is basically adding the right type of gradient to the reflected images alpha/matte channel.richo wrote:Important is that the shadow is not complete image just a part.
Bonzo did the right thing for an initial result, used a linear gradient. You probably want to either adjust the slope of that gradient to make it fully transparent faster, OR use something like a -sigmodial-contrast on the gradient (before it is added) to make it fall off very fast but then slow down as it approaches full transparency.
It is only a matter of tweeking to get exactly what you want.
How about posting a image of your results?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to make reflected Image thumbnails
I will be working on it tonight.
Here is the effect what I like to create.
You can see that image is not really reflected on bottom, just borders.
I like make it better with a little reflection.
Here is the effect what I like to create.
You can see that image is not really reflected on bottom, just borders.
I like make it better with a little reflection.
Re: How to make reflected Image thumbnails
This will do part of what you want ( looks better on a black background ).
Code: Select all
// Change my image to black and white and add a border
exec("convert House.jpg -colorspace Gray -bordercolor white -border 10x10 temp1.png");
// Create reflected image and crop to retain the bottom part of the image; also add a black border to the top and bottom of the image to space them out when joined.
exec("convert ( temp1.png -flip -bordercolor black -border 0x5 ) -crop 303x70+0+0 temp2.png");
// Make a gradiant - transparent to black
exec("convert -size 303x500 gradient:none-black gradient_fx_linear.png ");
// Put the gradiant over the inverted image
exec("convert temp2.png gradient_fx_linear.png -gravity south -composite temp3.png");
// Join the two images together
exec("convert temp1.png temp3.png -append temp4.png");
Re: How to make reflected Image thumbnails
Is it possible to get size of image automatically so I can define for example 20% from it in next command?
Re: How to make reflected Image thumbnails
I work with php and you can use getimagesize(), there may be otherways of doing it but how are you using your code ?