Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crop Photos

Status
Not open for further replies.

zbphill

Technical User
Jan 30, 2007
40
US
I want to crop a picture.
I know how to in photoshop, and all the other programs.

I have clients uploading pictures(random height and width) and the pictures get displayed on the web, but I want them a to be all to be display a certain size with out stretching the picture.

Any Idea, tutorials, or programs out there.

thanks
Zach
 
I have clients uploading pictures(random height and width) and the pictures get displayed on the web, but I want them a to be all to be display a certain size with out stretching the picture.

> So, you do not want "crop", but resize.
 
No, No crop and resize.

so if they upload a picture of a house,
Lets say that the box I want to display the picture is w= 250px & h= 100. The picture they upload is h= 500px & w= 500px. I want the picture to fill that box proportionally with out white space.

thanks again.
 
The Image webControl has a width and a height properties. If you leave then blank, then the image that will load will take the actual length. If you set - before setting the .ImageURL property - the height and the width of the control, then the image will fit exactly in the Image control.
Try it and see it!

Now, before setting the image and the dimmensions of the control, get the size of the picture (in the server), divide by 2 and set the results in the width and height. Then assigne the imageURL property.


Do you understand my way of thinking?
Hopw this helps !
 
... The divide by 2 is wrong. I saw the "w= 500px" as "w= 200px" by mistake. Just assign the w= 250px & h= 100px .. and you are ok.
 
What I think he's going for is something like a 100x100 thumb nail image. People can upload images of any size/aspect ratio though, it may be a 1024x1024 image, or it may be a 640x480 image, or any other combination.

You're going to have to scale the image (with the aspect ratio locked) so that the smallest measurement of the image is the same size as the goal size, then crop the left overs from the other side.

If you want a 100x100 image and the user gives you a 200x500 image. You would resize the image to be 100x250, then crop 75 pixels off the top and the bottom.

Bitblt isn't nearly as scary as it looks at first glance and it can do just that in 2 lines of code (if you do the math inline).

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Yes, Rick is right... I just took for granted that the image would be 500x500 as zbphill said. Well, if this is standard then you can have the Image control's w&h properties pre-set.

Else - which i also do think that will be happening - is that the image can be at any dimmension. In that case as you said, you resize (aspect ratio locked) the picture (resize by the smallest dimmension) and then remove the "exceeding" (must be spelled wrong :p) pixel 'lines' or 'columns'.

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top