randomimage scale

hi, firstly i'd like to say how pleased i am with the system. thanks!

However i have a slight issue that i have not been able to fix myself or find an answer for here..

i have been hacking up the evanescence theme and i am using the randomimage function to create a banner for the header.

for this, i have told functions.php to make the image 900px wide (the width of my site and the original photos size). however, i notice that the function doesn't simply crop a 900px strip from the images, it crops a section then upscales it to 900px.

This means that my banner becomes quite pixelated, which is a shame.

Is there any way to get the function to simply crop a 900px section of the image and display it at the same scale? all my images are 900px wide.

thanks for any help.

luke

Comments

  • acrylian Administrator, Developer
    Do you have upscaling deactivated on the image options? Also you need to experiment a little with the custom image parameters (those within that random function). How they work is within the comment of `zp-core/i.php`. Also there has been a lengthy thread about similar things some time ago.
  • hi, thanks for the fast response. i have upscaling off.

    to be honest with you, this is getting way beyond my level of experience with this type of code.

    i looked at i.php. and i understand it lists the parameters and what they do, however i see no mention of any of the ones i need (cw, ch, cx, cy) in either the i.php script or within the randomimage function, and since my ability is limited to fiddling with digits that are already there and hacking code up, rather than making anything new, could you please direct me to the previous thread you mentioned? i can't seem to find it, and it sounds like it might help.

    thanks again.
  • hold on, i found image-functions.php...

    will this help?

    im having a look, will report back, but could still use some help!

    edit: afraid that didnt help, i saw alot of mentions of the parameters names i needed, but no digits that i could simply change to tell it to crop an area of 900px wide before resizing it (which it wont have to do since the final image will need to be 900px too.)
  • acrylian Administrator, Developer
    Look at efferescence > functions.php where you will find around line 41 within the PrintHeadingImage() custom function this line:
    `htmlspecialchars($randomImage->getCustomImage(NULL, $wide, $high, $wide, $high, NULL, NULL, !getOption('Watermark_head_image'))).`

    The parameters of the method are exactly those described on `i.php`. They are also described on the doc of this method.

    You can't simple tell it to crop 900x wide before resizing exactly. the cropwidth needs to be bigger than the width to achieve a kind of similar thing. These settings are general and of course images can be of different sizes so there can't be such a function (no matter if your images are all the same). As said you need to experiment with the setting.
  • `
    $randomImageURL = htmlspecialchars(getURL($randomImage));
    if (getOption('allow_upscale')) {
    $wide = 900;
    $high = 180;
    } else {
    $wide = min(900, $randomImage->getWidth());
    $high = min(180, $randomImage->getHeight());
    }
    echo "imagegetCustomImage(NULL, $wide, $high, 900, 180, 0, 200, !getOption('Watermark_head_image'))).
    "' width='$wide' height='$high' alt=".'"'.
    htmlspecialchars($randomAlt1, ENT_QUOTES).
    ":\n".htmlspecialchars($randomImage->getTitle(), ENT_QUOTES).
    '" />
    ';
    }
    echo '';
    `
    SUCCESS!

    the 0 represents the distance from the left ($cx) of the image at which the script starts to crop, the 200 represents the distance from the top ($cy).

    thankyou for your help and patience. as i said i haven't played with php this deeply before.
Sign In or Register to comment.