How can I upload Animated .gif without resize ?
Posted: Mon Apr 28, 2014 10:22 pm
Hi All.
I would like to upload animated GIF images for the product image ,Is this possible with OpenCart. 1.513 upload without resize ?
I search the forum and it is difficult to find the solution.
Method one :
Another workaround could be to edit your "catalog/controller/product/product.php". Find the following line (around line 179):-
And replace it with:
This will then use the "original" image for the product thumbnail, rather than a resized image.
But I get nothing and blank ,no mainimage when I 'm using above CODE ??
Method Two
http://forum.opencart.com/viewtopic.php?t=24967
Description: The current image library properly handles resizing JPEG and PNG (including those with alpha) correctly, but fails to preserve transparency with GIF images. This patch fixes that.
In Method Two , I confuse the above code ....Is it correct ? Can I use it ?
I just want to upload Only GIF FORMAT Image to completely bypasses the image resizing function ! Can anyone Help Me Please !!!!
Thanks
Ken
I would like to upload animated GIF images for the product image ,Is this possible with OpenCart. 1.513 upload without resize ?
I search the forum and it is difficult to find the solution.
Method one :
Another workaround could be to edit your "catalog/controller/product/product.php". Find the following line (around line 179):-
Code: Select all
$this->data['thumb'] = $this->model_tool_image->resize($image, $this->config->get('config_image_thumb_width'), $this->config->get('config_image_thumb_height'));
Code: Select all
$this->data['thumb'] = $image;
This will then use the "original" image for the product thumbnail, rather than a resized image.
But I get nothing and blank ,no mainimage when I 'm using above CODE ??
Method Two
http://forum.opencart.com/viewtopic.php?t=24967
Description: The current image library properly handles resizing JPEG and PNG (including those with alpha) correctly, but fails to preserve transparency with GIF images. This patch fixes that.
Code: Select all
--- system/library/image.php Wed Sep 29 23:03:52 2010
+++ system/library/image.php Mon Jan 03 16:51:28 2011
@@ -72,17 +72,32 @@
$image_old = $this->image;
$this->image = imagecreatetruecolor($width, $height);
- if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') {
+ if (isset($this->info['mime']) && $this->info['mime'] == 'image/png') {
+
imagealphablending($this->image, false);
imagesavealpha($this->image, true);
$background = imagecolorallocatealpha($this->image, 255, 255, 255, 127);
imagecolortransparent($this->image, $background);
+ imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
+
+ } else if (isset($this->info['mime']) && $this->info['mime'] == 'image/gif') {
+
+ $transparent_index = imagecolortransparent($image_old);
+ if ($transparent_index >= 0)
+ {
+ imagepalettecopy($image_old, $this->image);
+ imagefill($this->image, 0, 0, $transparent_index);
+ imagecolortransparent($this->image, $transparent_index);
+ imagetruecolortopalette($this->image, true, 256);
+ }
+
} else {
+
$background = imagecolorallocate($this->image, 255, 255, 255);
+ imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
+
}
-
- imagefilledrectangle($this->image, 0, 0, $width, $height, $background);
-
+
imagecopyresampled($this->image, $image_old, $xpos, $ypos, 0, 0, $new_width, $new_height, $this->info['width'], $this->info['height']);
imagedestroy($image_old);
I just want to upload Only GIF FORMAT Image to completely bypasses the image resizing function ! Can anyone Help Me Please !!!!
Thanks
Ken