473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Crop Image

Hi there,
I was wondering if there was a way to crop a peice of an ASP.Net Image,
allowing the user to zoom in on only a section of the picture??

any help would be appreciated!!
thanks
--
Ad****@hotmail.com
Nov 19 '05 #1
3 8440
Yes. You would have to manipulate the image on the server side. So, it would
be done by doing a PostBack, altering the image, and using an ASPX page to
return the cropped image to the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"ACaunter" <Ad****@hotmail.com> wrote in message
news:3E**********************************@microsof t.com...
Hi there,
I was wondering if there was a way to crop a peice of an ASP.Net Image,
allowing the user to zoom in on only a section of the picture??

any help would be appreciated!!
thanks
--
Ad****@hotmail.com

Nov 19 '05 #2
Hi Kevin,
Thanks for the reply. Would you be able to provide any code samples of how
i could do this.. I'm still pretty new to ASP.Net and don't really know what
you're talking about..Just whatever the quickest/easiest way is to zoom in on
a cropped part of an image..

thanks so much!!

"Kevin Spencer" wrote:
Yes. You would have to manipulate the image on the server side. So, it would
be done by doing a PostBack, altering the image, and using an ASPX page to
return the cropped image to the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"ACaunter" <Ad****@hotmail.com> wrote in message
news:3E**********************************@microsof t.com...
Hi there,
I was wondering if there was a way to crop a peice of an ASP.Net Image,
allowing the user to zoom in on only a section of the picture??

any help would be appreciated!!
thanks
--
Ad****@hotmail.com


Nov 19 '05 #3
Hi Adam,

I'm afraid you picked the wrong guy for code samples. I generally don't give
out code samples, except for small examples of syntax. I feel that I'm not
doing anyone any good by doing their work (writing their code) for them. It
doesn't make them a better prgrammer; it makes them a lazier programmer. I
do get some flack for it, but I have to obey my conscience in these matters.

I will tell you in more detail what you need to do, and hopefully you should
be able to take it from there:

The first thing we need to do is analyze the problem. This begins with
requirements. At this point, I would have to say that your requirements are
not well-defined. For example, the first thing you mention is:
I was wondering if there was a way to crop a peice of an ASP.Net Image
That's all well and good. We know what cropping is, but we have yet to
define the mechanism by which the user will instruct your app to crop the
image. Cropping is done in a number of different ways, depending upon the
app. Cropping is the process of reducing the horizontal and/or vertical
size, by eliminating pixels from one or more edges of the picture. So, when
cropping, one must determine how many pixels do we drop from which edges?

Now, we mentioned that there are many apps that crop images, and that they
do this in any number of ways. For example, in some apps, you click and drag
the cursor to define a rectangle inside the image. This rectangle's size and
location determine how much (if any) to trim from each edge of the image.
But we're talking about a browser here. Is it possible to draw a rectangle
over an image using HTML and JavaScript? Yes, but it's complicated.
Basically, you have a hidden Div on the page. When you click the mouse over
the image, the div is moved (via JavaScript) to the point where you click.
Initially, the Div is 1X1 pixel. As you drag, the div is resized so that the
width and height correspond to the difference between the XY of the upper
left-hand corner of the div to the mouse position. The div is positioned
above (Z-order) the image, and the edges become visible, so that you see the
outline of the rectangle. When you release the mouse, JavaScript records the
location and dimensions of the rectangle, relative to the image.

Once you have determined the amount to crop from each edge, you need to
transmit it to the server. This would be done via PostBack. Possibly, you
would populate 4 hidden form fields with the numbers of pixels to crop from
each edge. Once the PostBack occurs, you read the 4 hidden form fields to
determine how much to crop from each edge.

Now for the tricky part (oh, you thought THAT was the tricky part?). How do
we modify the image and return it to the Page? Well, an HTML document
doesn't actually contain images; it contains references to their URLs, so
that the browser can download and display them where they ought to be. So,
the first thing you need is an ASPX page that functions as an image. This is
done by creating an ASPX page that either creates or fetches an image, sets
the Response.ContentType to "image/jpg" (whatever the appropriate MIME type
is), and then saves the image to the Response.OutputStream. Now, this might
seem a bit confusing, as the page has an ASPX extension. But the browser
will ignore that if you set the MIME type.

The page which contains the image must point to this ASPX page to get the
image. One method of calling such an image page is to use QueryString
parameters in the URL. For example:

<img src="Image.aspx?image=someimage.jpg&left=10&right= 10&top=20&bottom=25>

The page reads the QueryString and custom-delivers the image dynamically.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"ACaunter" <Ad****@hotmail.com> wrote in message
news:75**********************************@microsof t.com... Hi Kevin,
Thanks for the reply. Would you be able to provide any code samples of
how
i could do this.. I'm still pretty new to ASP.Net and don't really know
what
you're talking about..Just whatever the quickest/easiest way is to zoom in
on
a cropped part of an image..

thanks so much!!

"Kevin Spencer" wrote:
Yes. You would have to manipulate the image on the server side. So, it
would
be done by doing a PostBack, altering the image, and using an ASPX page
to
return the cropped image to the browser.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"ACaunter" <Ad****@hotmail.com> wrote in message
news:3E**********************************@microsof t.com...
> Hi there,
> I was wondering if there was a way to crop a peice of an ASP.Net Image,
> allowing the user to zoom in on only a section of the picture??
>
> any help would be appreciated!!
> thanks
> --
> Ad****@hotmail.com


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Kevin Smith | last post by:
Is there a way to "auto-crop" an image in PIL? I have some PNG images with white backgrounds that I want cropped to show only the non-white portion in the center, but I don't see how I can do...
3
by: Stimp | last post by:
I've been hacking at this for 15 mins, but haven't really got too much time to spend on it today, so maybe someone here can suggest a quick fix or suggest if there is a function built into asp.net...
2
by: Poppa Pimp | last post by:
ImageResizer.php Image Resizer PLEASE HELP The URL of the page this is on in my site is http://poppa-pimps-wallpapers.com//ImageResizer.php You can click on browse and get image,but...
1
by: arunbalait | last post by:
I want to crop an image in VB and to store the cropped image in another image box or any... I want source code samples
3
by: svsenthilkumar | last post by:
Hi, i want to crop a selected image from PDF Document and copy that and save it as a jpg image. how can i access the crop image and save as a jpg or gif file format. please give me some...
1
paulrajj
by: paulrajj | last post by:
hi, i am newbie to PHP and javascript. i need simple example to crop image using PHP and javascript.. thanks in advance..
1
Thekid
by: Thekid | last post by:
Hi, I have an image similar to a clock, with numbers and letters going around in a circle. I need to extract the numbers and letters from the image and have them print out in a straight line and in...
2
by: vishal1082 | last post by:
i want to take a screenshot of user's desktop, just like printscreen does and crop it, because i just want the system tray of taskbar is it possible? (system tray == notification area)
1
by: koyanpaing | last post by:
Hello everyone, I am using image cropping tools moocrop for cropping image. I would like to know the meaning of crop5.addEvent('onDblClk', function(img,crop,bound){ $('cropped').src =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.