D
daveh551
I have done a Google search on this, and the hits seem to indicate
that there's probably not a computationally easy way to do it, but
I'll ask anyway before I go off and re-invent the wheel.
I have user control do display a specified image file (.jpg) from a
database. Files may have arbitrary height, width, and aspect ratios.
I have height and width properties on the control to fit the image
display into the appropriate space on the page. But I would like to
do that while maintaining the aspect ratio of the original image,
rather than just leaving it up to the browser to scale to the
specified height and width. This would require me to adjust the
requested height and width property to maintain the aspect ratio of
the original file, which I have no problem with... except that I don't
have an easy way get the original height and width.
Is there an easy way to do this in ASP.NET? I don't mind writing code
in the code-behind file to do it, but is there a way to do it without
reading in the whole JPG file (and then reading it again when it's
loaded by the HTML)? It seems like this would be a fairly common
problem, so I'm sure there are some classes out there to do it, maybe
even within .NET itself, though the impression I got from the Google
hits was that the JPEG file format definition is such that you're
going to have read the whole file (or most of it) to extract the
information.
Is this computationally intensive enough to make it worth storing in a
database table and looking it up first, only reading the file to find
it if it's not in the DB table (and then adding it)?
that there's probably not a computationally easy way to do it, but
I'll ask anyway before I go off and re-invent the wheel.
I have user control do display a specified image file (.jpg) from a
database. Files may have arbitrary height, width, and aspect ratios.
I have height and width properties on the control to fit the image
display into the appropriate space on the page. But I would like to
do that while maintaining the aspect ratio of the original image,
rather than just leaving it up to the browser to scale to the
specified height and width. This would require me to adjust the
requested height and width property to maintain the aspect ratio of
the original file, which I have no problem with... except that I don't
have an easy way get the original height and width.
Is there an easy way to do this in ASP.NET? I don't mind writing code
in the code-behind file to do it, but is there a way to do it without
reading in the whole JPG file (and then reading it again when it's
loaded by the HTML)? It seems like this would be a fairly common
problem, so I'm sure there are some classes out there to do it, maybe
even within .NET itself, though the impression I got from the Google
hits was that the JPEG file format definition is such that you're
going to have read the whole file (or most of it) to extract the
information.
Is this computationally intensive enough to make it worth storing in a
database table and looking it up first, only reading the file to find
it if it's not in the DB table (and then adding it)?