Moshe
Total Posts: 1771
Joined: 2007-08-07
Los Angeles
@Andrew Smith: you could copy this file to app/code/local/Varien/Image/Adapter/Gd2.php and update it there.
Signature
- I would love to change the world, but they won’t give me the source code -
gavh
Total Posts: 27
Joined: 2008-04-01
The javascript addition is great. How would you center the image?
chezky
Total Posts: 3
Joined: 2007-11-06
ryu007 - 07 April 2008 12:04 PM
In order to resolve image proportion, replace this old method with this new :
in lib/Varien/Image/Adapter/Gd2.php :
public function resize ( $dstWidth = null , $dstHeight = null ) { if( !isset( $dstWidth ) && !isset( $dstHeight ) ) { throw new Exception ( "Invalid image dimensions." ); } if( !isset( $dstWidth ) ) { $width2height = $this -> _imageSrcWidth / $this -> _imageSrcHeight ; $dstWidth = round ( $dstHeight * $width2height ); } elseif( !isset( $dstHeight ) ) { $height2width = $this -> _imageSrcHeight / $this -> _imageSrcWidth ; $dstHeight = round ( $dstWidth * $height2width ); } /* if( $this->keepProportion() ) { if ($this->_imageSrcWidth / $this->_imageSrcHeight >= $dstWidth / $dstHeight) { $width = $dstWidth; $xOffset = 0; $height = round(($width / $this->_imageSrcWidth) * $this->_imageSrcHeight); $yOffset = round(($dstHeight - $height) / 2); } else { $height = $dstHeight; $yOffset = 0; $width = round(($height / $this->_imageSrcHeight) * $this->_imageSrcWidth); $xOffset = round(($dstWidth - $width) / 2); } } else { $xOffset = 0; $yOffset = 0; $width = $dstWidth; $height = $dstHeight; } */ if ( $this -> _imageSrcWidth / $this -> _imageSrcHeight >= $dstWidth / $dstHeight ) { $width = $dstWidth ; $height = round ( $this -> _imageSrcHeight * $width / $this -> _imageSrcWidth ); $yOffset = round (( $dstHeight - $height ) / 2 ); $xOffset = 0 ; } else { $height = $dstHeight ; $width = round ( $this -> _imageSrcWidth * $height / $this -> _imageSrcHeight ); $yOffset = 0 ; $xOffset = round (( $dstWidth - $width ) / 2 ); } $imageNewHandler = imagecreatetruecolor ( $dstWidth , $dstHeight ); if( ! $this -> keepProportion () ) { $bgcolour = imagecolorallocate ( $imageNewHandler , 255 , 255 , 255 ); // white background imagefill ( $imageNewHandler , 0 , 0 , $bgcolour ); $width = round ( $this -> _imageSrcWidth * $height / $this -> _imageSrcHeight ); if ( $width < $dstWidth ) { $xOffset = floor (( $dstWidth - $width ) / 2 ); } } if ( $this -> _fileType == IMAGETYPE_PNG ) { $this -> _saveAlpha ( $imageNewHandler ); } imagecopyresampled ( $imageNewHandler , $this -> _imageHandler , $xOffset , $yOffset , 0 , 0 , $width , $height , $this -> _imageSrcWidth , $this -> _imageSrcHeight ); $this -> _imageHandler = $imageNewHandler ; $this -> refreshImageDimensions (); }
Respect orginal dimensions and constraint width or height.
Hard for me to translate properly in english (shame on me) but you will understand after some test.
Cheers,
Ilan
Ilan, I updated gd2.php but nothing actualy changed my images are still not in proportion. is there anything else exept gd2.php that needs to be updated? Please help.
Chezky
Flowstack
Total Posts: 130
Joined: 2008-01-30
London, United Kingdom
@chezky - Obvious I know, but have to ask: Did you refresh cache?
macflux
Total Posts: 4
Joined: 2008-05-26
Flowstack - 15 May 2008 12:40 AM
@chezky - Obvious I know, but have to ask: Did you refresh cache?
im having the same trouble after refreshing the cache...the image is still stretched to the square format
Daniel_79
Total Posts: 23
Joined: 2008-04-19
I’m also having some problems with the scaling of images
I created a 135x135 image in photoshop and upload it, then magento seems to rescale it to 135x135 again using some technique that warps the image slightly.
I am attaching the two images to this reply.
original.jpg is the image I upload
magento version.jpg is the file saved on magento server, if you look at the red area you will see some difference in the colors (you have to click to open in full size to see how the orignail should look)
Image Attachments
Click thumbnail to see full-size image
ukdazza
Total Posts: 162
Joined: 2008-04-16
Flowstack - 04 April 2008 05:59 AM
1. Open default/template/catalog/product/view/media.phtml.
Ed
Right, am I being thick or is this not a complete directly series?...I dont have a “default” or “template” .... sorry if being thick but where does one look for this file?
oxygen
Total Posts: 55
Joined: 2008-06-09
hi Moshe, I followed your method and it works fine for my images, except, the thumbnail at the RELATED PRODUCTS (right hand bar), still the same.
However, the thumbnail on MY CART/Recently Added Items, is ok.
Anyone can help? Please?
Thank you.
redsuperhawk
Total Posts: 7
Joined: 2008-03-02
I would just like to say thank you to those who have offered the solution to this problem. You save me some major headaches, and I greatly appreciate that!
Jeff
redsuperhawk
magentomatt
Total Posts: 28
Joined: 2008-08-08
just wanted to thank everyone for you’re contributions here. It helped me quite a bit (i have no idea what i’m doing)
Thejosh13
Total Posts: 101
Joined: 2008-06-23
Does this fix file need to updated for the more recent releases of Magento?