Post by tierra » Tue Jan 04, 2011 8:13 am

I'm duplicating this post from the bug tracker entry since it seems to mangle patch text (should be easier to use patch attached here).

Bug Tracker Entry: http://www.opencart.com/index.php?route ... bug_id=165

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);
            
P.S. It would be nice if either the bug tracker had a way of attaching patches, or these forums allowed .patch files.

Newbie

Posts

Joined
Tue Dec 14, 2010 5:55 pm

Post by marc_cole » Tue Jan 04, 2011 8:19 am

Why don't you post this patch as a VQMod file instead? It's a pretty handy way of patching the core code and, especially if you're not handy with patch files, a lot easier to apply the changes.

Marc

OpenCart v1.4.9.4
VQMod | Categories Home | Cleaner By Default - 2 Column | Speak Good English


Active Member

Posts

Joined
Tue Dec 14, 2010 11:26 am
Location - Seattle, WA

Post by Qphoria » Tue Jan 04, 2011 8:34 am

Yea its not really a bug.. it was something i was just trying and only decided to support png files at the time until it was deemed working. I just need to add gif support as well.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by tierra » Tue Jan 04, 2011 8:55 am

marc_cole wrote:Why don't you post this patch as a VQMod file instead? It's a pretty handy way of patching the core code and, especially if you're not handy with patch files, a lot easier to apply the changes.
The patch file is here for OC maintainers to quickly apply the fix to the official code, so everyone benefits. I've already applied this to my installations of OC. VirtualQMod really doesn't have anything to do with this.

Newbie

Posts

Joined
Tue Dec 14, 2010 5:55 pm

Post by Qphoria » Tue Jan 04, 2011 9:44 am

I actually have a phppatching class that can parse and apply patch files.. But patching is so passé now that vqmod is around :)

But you are right.. for something like this, it should be done in the core as it was left unfinished.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by minhhieu493 » Sat Feb 05, 2011 11:24 am

i changed image.php but it doesn't work, you can send me it? My email is minhhieu87@gmail.com

Newbie

Posts

Joined
Sat Feb 05, 2011 9:51 am

Post by Daniel » Sun Feb 06, 2011 6:55 pm

resized gifs using transparent backgrounds generated by php normally look very bad. we will probably getting people reporting bugs about this aswell.

this is not a bug at all. jpgs are used because you are soposed to use jpgs for product images. just like camera images are jpg.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by peteVA » Mon Feb 07, 2011 2:10 am

Another head in the sand reply from the lead developer.

Daniel, any idea how many shirts would be sold it they were all just black tees? - http://electro-tees.com/

The sales point, the entire purpose of buying these shirts is the "action" and I can tell you for a fact that putting them up as jpgs can have all sorts of results, depending on which layer you manage to catch them in as a jpg.

Wake up and smell the coffee, action sells, it's not all black and white, 2-dimensional out there in Internet land.

Note on this page, and then the product page, the watch at the lower right - http://wholesale-district.com/dropship/ ... ED_Watches

The process to get that flashing went like this -

Try just importing the gif through the image manager - flat black no time showing.

Upload a gif to the Images/Data/LED Watches folder by FTP and then choosing in the Image Manager - same results, became jpgs and no digital reading.

As with the electro tees, I ended up creating 40x40, 100x100, 172x172, 250x250 and 500x500 gifs on my PC, then uploading to Images/Cache/Data as gifs, deleting the jpgs that were already there from my import attempts and then RENAMING the GIFs to JPGs in order to get them working as designed.

Daniel, you need to understand that while you may be a coder, you are not a marketer or merchandiser and being able to display actively working GIFs for certain products is vital to make them appealing to potential buyers.

So, instead of blowing off yet another valid comment, why not devote some time to improving what is probably the weakest part of your entire efforts - the Image Manager and get it where is will at least accept (and hopefully resize) GIFs.

Resizing GIFs is not an ordinary thing, I've spent much time searching and this is about the only thing I found that will do it - and it's FREE - http://www.ashongsoft.com/gif.resizer.documents.html

A Trusted Wholesale Dropshipper
Web Hosting Under $ 5.00 Month! FREE Shopping Carts!
25,000+ Real Wholesale & Dropship Sources!


User avatar
Active Member

Posts

Joined
Mon Jul 20, 2009 8:25 am

Post by minhhieu493 » Mon Feb 07, 2011 10:58 pm

So,can i use original image when popup? How? Thanks for help!

Newbie

Posts

Joined
Sat Feb 05, 2011 9:51 am

Post by Qphoria » Tue Feb 08, 2011 9:50 am

peteVA wrote:Another head in the sand reply from the lead developer.
A very arrogant yet ignorant response. Daniel clearly stated "generated by php" look bad.. this is extremely factual. Resizing images using code libraries is the equivalent of using MS Paint for your website graphics.. yea it can be done.. but not recommended. The same goes with gifs. I managed to get transparency working for png files and as long as the original picture is decent, the generated images are decent. But I spent a few days trying to get animated gifs to work right using php resizing code and it turned to crap.

Don't let your desire to be able to specify properly resized images for each size level blur your vision on what can't and shouldn't be done by a php library. Yes it is a good idea to allow bypassing the resizing feature of opencart and that will likely be done in the future.. But resizing gifs using php will not be included. Transparency is one thing, but "action" is something completely different.

Image
Donate!|OpenCart Basics|GeoZones
Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by peteVA » Tue Feb 08, 2011 10:42 am

I know nothing about anything you said, Q. I do know how to do what I want done, though it's quite a chore with hundreds of images.

And I was not saying anything about heads in the sand regarding the process, or lack of process of using or resizing gifs.

I was referring to this line
jpgs are used because you are soposed to use jpgs for product images
(no spell checker?)

I think people selling products are SUPPOSED to use whatever tools they can to help increase sales. Far too often with cart coders it is more the coding and the files than it is the end result. The end result that thousands start out looking for is increased sales and if animated gifs can help a cart owner increase sales they should not be blown off by a developer, whether the coder can make them happen or not, they can still be useful.

The fact is that simply resizing animated gifs is not a simple process, in or out of a php environment. I can understand the difficulty or even the impossibility of OC or any cart to perform the function. My only reason for writing the head in the sand part is the "I know it all" or "my way or the highway" attitude that is often how Daniel replies to what he apparently takes as direct threats to his manhood when someone points out a shortcoming of the cart.

At times I wonder how many good, decent users or possible users he has run off.

I did also mean what I said about the Image Manager. That was not in regard to gifs, it's just a total pain in the ass to work with, no matter how you look at it.

From the stupid "Add Image" on the right, then having to move totally across the screen to the left to click on an image to actually add an image is a lot of wasted motion when entering hundreds of images.

As is having to "drill down" into the sub-folders when adding several images to the same product. Why not go back to the same folder, if you are adding a new item to a category and have the images for that category in their own folder, then it makes sense (aren't coders supposed to think logically?) that if you are entering 5 "additional images" to a product that they will all be in the same category folder. No Chinese menu sort of thing where you get one image from this folder and then the next from a second folder, etc.

I've mentioned before having page numbers at the top and bottom of the product pages. Why scroll all the way to the bottom of page one when you know you want to go to page 3?

Same with Save buttons. Why scroll all the way to the top when you finish at the bottom? Why not have buttons and page links, etc. top and bottom? Add 14 options and then have to scroll up a 2 foot long page to save them? Why not a button down below?

A Trusted Wholesale Dropshipper
Web Hosting Under $ 5.00 Month! FREE Shopping Carts!
25,000+ Real Wholesale & Dropship Sources!


User avatar
Active Member

Posts

Joined
Mon Jul 20, 2009 8:25 am

Post by minhhieu493 » Tue Feb 08, 2011 11:37 pm

I want to show gif image of product in popup or product page, who can help me? thanks so much.

Newbie

Posts

Joined
Sat Feb 05, 2011 9:51 am
Who is online

Users browsing this forum: No registered users and 10 guests