Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • nojaf 91 posts 300 karma points
    Jan 03, 2014 @ 11:21
    nojaf
    0

    Messed up ratio

    Hi there,

    I'm trying the following code:

    <img src="/imagegen.ashx?width=325&amp;height=200&amp;contrain=true&amp;image=@img&amp;crop=resize&amp;align=center&amp;AllowUpSizing=true" alt="" />
    

    But the ratio is messed up, what am I missing here?

  • Douglas Robar 3570 posts 4670 karma points MVP 6x admin c-trib
    Jan 03, 2014 @ 13:36
    Douglas Robar
    100

    Hi, nojaf,

    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:

    imagegen.ashx?image=test.jpg&width=325&height=200&crop=resize&allowupsizing=true
    

    As a minor side note, you don't need to use &amp; with Razor. You can use the & character directly in Razor (only with xslt do you need to escape the & to become &amp;). It does no harm to have the escaped ampersands but it is tidier and easier to read with the single character I think.

    cheers,
    doug.

  • nojaf 91 posts 300 karma points
    Jan 03, 2014 @ 15:03
    nojaf
    0

    Hi Doug,

    Thanks, your solution works! Have a great weekend!

    nojaf

  • nojaf 91 posts 300 karma points
    Jan 07, 2014 @ 17:29
    nojaf
    0

    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?

  • Douglas Robar 3570 posts 4670 karma points MVP 6x admin c-trib
    Jan 07, 2014 @ 17:51
    Douglas Robar
    0

    Hi, Nojaf,

    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.

    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?

    cheers,
    doug.

  • nojaf 91 posts 300 karma points
    Jan 08, 2014 @ 09:21
    nojaf
    0

    Hello Douglas,

    I've installed ImageGen with the package manager of Umbraco.

    And my config looks like this:

    <?xml version="1.0" encoding="utf-8" ?>
    <ImageGenConfiguration>
      <Registration>
        <!-- ImageGen Professional is always available on localhost and *.local domains -->
        <Key domain="example.com">436DA8888A3BBC98662B23C6D1B635543E762854</Key>
        <Key domain="sample.com">55FD8FD97A199AB3082BC7DC11AE5F743B092C55</Key>
     </Registration>
     <RemoteDomainWhiteList>
        <Domain>www.sample.com</Domain>
     </RemoteDomainWhiteList>
    
     <!-- SAMPLE NAMED CLASSES, INCULDING THE SPECIAL 'DEFAULT' CLASS -->
     <Class Name="default" OverridesQueryString="true">
       <AllowUpsizing>true</AllowUpsizing>
       <MaxHeight>800</MaxHeight>
       <MaxWidth>800</MaxWidth>
     </Class>
     <Class Name="Thumbnail" OverridesQueryString="true">
       <InheritFromClass>default</InheritFromClass>
       <Width>200</Width>
       <Height>200</Height>
       <CachingTimeSpan>3600</CachingTimeSpan>
    </Class>
    </ImageGenConfiguration>
    

    Oh yeah and another quick question, where are the images being cached? Which directory precise?

  • Douglas Robar 3570 posts 4670 karma points MVP 6x admin c-trib
    Jan 08, 2014 @ 10:50
    Douglas Robar
    0

    Hi, Nojaf,

    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:

    http://preview.ferventreisagent.be/imagegen.ashx?version

    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.

    cheers,
    doug.

Please Sign in or register to post replies

Write your reply to:

Draft