Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying the following code:
<img src="/imagegen.ashx?width=325&height=200&contrain=true&image=@img&crop=resize&align=center&AllowUpSizing=true" alt="" />
But the ratio is messed up, what am I missing here?
You're really close! Remove the &constrain=true parameter and I believe you'll get what you want... and image that is 325x200 with any extra bits cropped off after the resizing (always showing the center portion) so that the image is precisely 325x200 when finished.
The &constrain=true parameter forces the final image to match the proportions of the original image. Normally you would want this but not when you're cropping, which can generate a new ratio of height and width.
This has been tested with ImageGen 2.9:
As a minor side note, you don't need to use & with Razor. You can use the & character directly in Razor (only with xslt do you need to escape the & to become &). It does no harm to have the escaped ampersands but it is tidier and easier to read with the single character I think.
Thanks, your solution works!
Have a great weekend!
Hello Douglas, I think my ratio is still being altered. I try this: The original image is: http://preview.be/media/2502/griekenland.jpg And the smaller image in an overview is: http://preview.be/europa-en-de-middellandse-zee It looks streched, am I seeing things here or making some errors?
Thanks for showing me samples of the issue, that's really helpful. What I've noticed is that the &crop= parameter is being ignored entirely. It doesn't matter what setting you have, it has not effect on the output. I also notice you're running v2.9.0.
I've just double-checked on a local v2.9.1 installation that the <img src=... /> you have should work as expected and not distort the aspect ratio of the image when using the &crop= parameter. There shouldn't be any difference between 2.9.0 and 2.9.1 in this regard but I note it just in case.
<img src=... />
More likely, you have settings in the imagegen.config file that are causing the different behaviour than expected. What do you have in the <class="default"> section of the imagegen.config file?
I've installed ImageGen with the package manager of Umbraco.
And my config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<!-- ImageGen Professional is always available on localhost and *.local domains -->
<!-- SAMPLE NAMED CLASSES, INCULDING THE SPECIAL 'DEFAULT' CLASS -->
<Class Name="default" OverridesQueryString="true">
<Class Name="Thumbnail" OverridesQueryString="true">
Oh yeah and another quick question, where are the images being cached? Which directory precise?
The 'cached' folder that contains the various resized images are created beneath the folder that contains the original image.
For instance, if you have a bunch of photos in the /images folder you'll find ImageGen creates the /images/cached folder. Or, if you have an image to resize in the /media/12345 folder ImageGen will create the /media/12345/cached folder. Depending on your site structure and the location of images you may have a few, or many, 'cached' folders.
As for why the crop parameter isn't working... it's because cropping is a professional feature and you are running the free version, which doesn't perform cropping. You'll see that you are running the Basic version by looking at:
If you've already purchased a domain key for ferventreisagent.be you'll need to add it to the <Key domain="ferventreisagent.be"> ... </Key> section of the imagegen.config file to activate the professional features for that domain and all sub-domains. You can purchase a key at http://www.percipientstudios.com/imagegen/purchase.aspx if needed.
<Key domain="ferventreisagent.be"> ... </Key>
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted