Results 1 to 2 of 2

Image resizing

This is a discussion on Image resizing within the Custom Mods and Hacks forums, part of the osCmax V2.5 Forums category; Hi, I have imported 760 products using EP and am now going through each product to update its product image. ...

      
  1. #1
    Member
    Join Date
    Jul 2012
    Posts
    71
    Rep Power
    1


    Default Image resizing

    Hi,

    I have imported 760 products using EP and am now going through each product to update its product image.

    I have update approximately 130 images and when using fixed width, the height is variable and affects the layout of the page.

    When I fix the height and width, the image becomes distorted and stretched.

    How can I ensure that the image is resize proportionately to its original size ?

    Thanks

  2. #2
    osCMax Development Team
    ridexbuilder's Avatar
    Join Date
    Jul 2008
    Location
    Haggisland
    Posts
    3,370
    Rep Power
    57


    Post Re: Image resizing

    For rectangular images, pad them out with white space (or transparency) until they are square.
    Example: new_width=width+abs(width-height)
    Irfanview is quick n easy at doing this sort of thing, enlarging canvas by half of the above, either side.

    Point of order: it is sizing proportionately - a tall narrow image will remain a tall narrow image, regardless of size - it is in proportion.

    If it suits your layout better, choose a fixed height and variable width.

    According to phpthumb (the image resizer) documentation:
    Thumbnails can be a fixed dimension regardless of source aspect ratio and background filled with configurable color...
    Perhaps someone has time to experiment.
    This would appear to be the function to use:
    Code:
        static function ScaleToFitInBox($width, $height, $maxwidth=null, $maxheight=null, $allow_enlarge=true, $allow_reduce=true) {
            $maxwidth  = (is_null($maxwidth)  ? $width  : $maxwidth);
            $maxheight = (is_null($maxheight) ? $height : $maxheight);
            $scale_x = 1;
            $scale_y = 1;
            if (($width > $maxwidth) || ($width < $maxwidth)) {
                $scale_x = ($maxwidth / $width);
            }
            if (($height > $maxheight) || ($height < $maxheight)) {
                $scale_y = ($maxheight / $height);
            }
            $scale = min($scale_x, $scale_y);
            if (!$allow_enlarge) {
                $scale = min($scale, 1);
            }
            if (!$allow_reduce) {
                $scale = max($scale, 1);
            }
            return $scale;
        }
    

    Last edited by ridexbuilder; 09-24-2012 at 06:23 AM. Reason: more info.
    Hosting plans with installation, configuration, contributions, support and maintenance.

Similar Threads

  1. RC1 image resizing
    By peterittner in forum Bugs and Problems
    Replies: 0
    Last Post: 09-20-2011, 10:42 AM
  2. Dynamic Image Resizing
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 09-06-2009, 11:01 AM
  3. Dynamic Image Resizing
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 07-13-2009, 06:50 PM
  4. image resizing
    By michael_s in forum New osCommerce Contributions
    Replies: 0
    Last Post: 11-12-2008, 12:10 AM
  5. Question about resizing pictures for website
    By markw10 in forum General Topics & Chit Chat
    Replies: 2
    Last Post: 07-21-2008, 02:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •