Client has a pro license, they
will be using ImageGen to resize images to a max width but the height
will be variable. The jQuery in use resizes the container with an
animation dependent on the size of each image being loaded. Whilst I
know the width I don't know the height of each image and therefore have
left the attribute off of the img tav but this is causing issues in some
browsers. So my question to you was, can I discover the height of the
resized image? If I use Crop I lose some of the image, if I use pad I
end up with unwanted background because the page background is
semi-transparent.
There's no super-convenient way to get the resulting height and width of a resized image coming back from ImageGen. If you tell ImageGen what height and width to live within you can use those settings in the <img height="200" width="200" src="/imagegen.ashx?image=photo.jpg&height=200&width=200" /> But if you are only interested in specifying one dimension and letting the other go to whatever size it turns out to be when resized... that's a very tough nut.
You could do the math yourself if it is a simple resize (without rotation, for instance). You can make a simple C# extension (usable by xslt, razor, .net) to get the original image's dimensions and then do the quick math based on the single dimension of the image you want back.
Or (not really recommended but I know some have done it)... search the index.xml file for the cached image and that will have the resulting height and width in it.
Or, since you're already using javascript... grab the returned image and get its properties and update the <img> tag client-side?
Hope this helps. Let us know how you finally decide to handle it.
Height of resized image is unknown
Client has a pro license, they will be using ImageGen to resize images to a max width but the height will be variable. The jQuery in use resizes the container with an animation dependent on the size of each image being loaded. Whilst I know the width I don't know the height of each image and therefore have left the attribute off of the img tav but this is causing issues in some browsers. So my question to you was, can I discover the height of the resized image? If I use Crop I lose some of the image, if I use pad I end up with unwanted background because the page background is semi-transparent.
Thanks, Si
There's no super-convenient way to get the resulting height and width of a resized image coming back from ImageGen. If you tell ImageGen what height and width to live within you can use those settings in the <img height="200" width="200" src="/imagegen.ashx?image=photo.jpg&height=200&width=200" /> But if you are only interested in specifying one dimension and letting the other go to whatever size it turns out to be when resized... that's a very tough nut.
You could do the math yourself if it is a simple resize (without rotation, for instance). You can make a simple C# extension (usable by xslt, razor, .net) to get the original image's dimensions and then do the quick math based on the single dimension of the image you want back.
Or (not really recommended but I know some have done it)... search the index.xml file for the cached image and that will have the resulting height and width in it.
Or, since you're already using javascript... grab the returned image and get its properties and update the <img> tag client-side?
Hope this helps. Let us know how you finally decide to handle it.
cheers,
doug.
is working on a reply...