Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Support thread for the Image Magic contribution


tomjmul

Recommended Posts

Hi Tom

 

Yes, it's a shared server, but the load it creates seems disproportionate to the calls it does.

Interestingly, what did speed it up about 25% was the following from the Contribs page......

 

"Instead of "&" I used "In order to get better HTML validation and SEO please do the following change in step 6 (/catalog/includes/functions/html_output.php) in Install Instructions (in README file)

 

//Return the html

$image = '<img src="imagemagic.php?img='.$src.'&w='. tep_output_string($width).'&h='.tep_output_string($height).'&page='.$page.'"'; "

 

I will look into your suggestion about recoding the page

 

Thanks,

 

Doc

Link to comment
Share on other sites

  • Replies 1.3k
  • Created
  • Last Reply

Top Posters In This Topic

Hi Tom

 

I understand the cache filenames apart from the last hex string

e.g. ft897s.jpg.thumb_100x80_3f6d9135b85b61e3c7f77a0c48ba0217.jpg and

ft897s.jpg.thumb_100x80_dd9e1a2566f58b29c89ea2fd3bd8a4c2.jpg

 

How are these generated and what do they mean? Are the files the same?

 

I can code the rest of it then.

 

Thanks,

 

Doc

Link to comment
Share on other sites

Doc,

 

I would almost certainly think that this problem has got to do with your host's filesystem.

 

The string you mention is the current hash of the configuration settings. This is needed so that if you change a configuarion value - say the watermark text, imagemagic will know not to use the file stored in the cache as it will no longer be valid (it will have the wrong watermark text.....get it :D )

 

This is no biggie, as you can reference this value everywhere in osc code by using the LAST_HASH constant.

 

Although, I haven't put much thought into this, I would probably tackle the issue with the following logic:

 

Maybe after here:

if (CFG_MASTER_SWITCH=="On") $calculate = true;

else $calculate=false;

 

1. split the $src variable into $file and $extension

2. put your thumbnail cache path into a var called $cache_dir

3. do a file_exists ($cache_dir.'/'.$file.'.thumb_'.$page.$.'x'.$width.'_'.LAST_HASH.'.'.$extension)

4. if the file does exist write the above string back into $src

5. set $calculate = false

 

 

The result hopefully is that i/m will not then interfere any more and the graphic will be served by way of the normal <img src=...> html tag.

 

Of course a side effect of this is that the image path and name can no longer be encrypted and it will give away the location of the non-cached version. But hey, what the hell.

 

Let me know how you get on. I am quite interested in the mod and may include the functionality in a future version.

 

Best wishes

Tom

Edited by tomjmul

OSC Image Magic

On-the-fly thumbnails, watermarks and image processing

Link to comment
Share on other sites

I have searched this forum and do not see my answer so if I somehow missed it, let me know...

 

I just installed the contrib but no images show up. I am still using the default product list. the image link include the IM info, but i cannot get any images to show up.

 

http://www.mnorris.net/collectibles/imagem...h=80&page=popup

 

I'd be happy to give you the UN/PW to access my site and look around, just let me know how. (AIM = Moose00000)

Link to comment
Share on other sites

I have searched this forum and do not see my answer so if I somehow missed it, let me know...

 

I just installed the contrib but no images show up. I am still using the default product list. the image link include the IM info, but i cannot get any images to show up.

 

http://www.mnorris.net/collectibles/imagem...h=80&page=popup

 

I'd be happy to give you the UN/PW to access my site and look around, just let me know how. (AIM = Moose00000)

 

OK - I couldn;t see where I could modify my previous post so here is an update...

 

It does not happen with JPG's, only the GIF's. I have tried turning on the GIF's to JPG's but it did not have any effect.

Link to comment
Share on other sites

Moose00000 this answers your issue... its the GD version you are runnung...

 

 

David,

 

Yes I see now.

This does seem to be a GD version problem, as earlier versions of GD don't handle gifs due to some sort of licensing wrangle.

Besides that, try this solution.

In your admin menu, select configuration -> images. Set both the width and height or category images to 0% and in configuration -> image magic, make sure that the process store graphics is set to false.

See if that solves the problem and if not, let me know

 

Tom

-Dave

Link to comment
Share on other sites

Moose00000 this answers your issue... its the GD version you are runnung...

 

my development server has:

GD Support enabled

GD Version bundled (2.0.12 compatible)

FreeType Support enabled

FreeType Linkage with freetype

GIF Read Support enabled

JPG Support enabled

PNG Support enabled

WBMP Support enabled

XBM Support enabled

 

 

I tried the above suggestion, but gifs still aren;t showing. My production server has a later version of GD. I haven;t tested on there yet. For now, I will only use JPG's...

 

my images configuration is...

 

Small Image Width 100

Small Image Height 0 Info

Heading Image Width 57 Info

Heading Image Height 0 Info

Subcategory Image Width 0 Info

Subcategory Image Height 0 Info

Calculate Image Size true Info

Image Required true Info

Product Information Image Width 120 Info

Product Information Image Height 0 Info

Edited by Moose00000
Link to comment
Share on other sites

Hi Tom

 

I'd already sussed where to put the code (I can follow the code fine!), but my php is pretty weak, so here goes........

 

if (CFG_MASTER_SWITCH=="On") $calculate = true;

else $calculate=false;

 

//Doc mod start $sql="select configuration_key as cfgKey, configuration_value as cfgValue from configuration where (configuration_group_id='333' or configuration_group_id='4')";

$result=@mysql_query($sql,$dbconn); //got config vars

 

$tpath=CFG_TN_CACHE_DIRECTORY;

 

if ($tpath{0}="/") $tpath2=str_replace("/","",$tpath);} else {$tpath2=$tpath;}

//Doc - my config var has leading slash, some may not??

$imagetest =$tpath2.$cache_dir."/".$src.".thumb_".$width."x".$height."_".LAST_HASH.strstr($src,".");

// Doc - strsrc on end of string is in case some use .jpeg extensions

if (file_exists($imagetest)) {

$image = '<img src="' . $imagetest . '"';

$calculate=false;

}

// end Doc mod

 

Speed is greatly improved, taking a fraction of the original time.

 

Doc

Link to comment
Share on other sites

Glad to hear it doc, well done.

 

Had a quick look over the code and wondering about the mysql stuff....this is redundant and you can take it out.

 

I'd already sussed where to put the code

 

One for all and all for one.....there will be others too doc. ;)

 

Tom

OSC Image Magic

On-the-fly thumbnails, watermarks and image processing

Link to comment
Share on other sites

Hi

First of all thanks for this awesome contrib!

 

It works very fine execpt the popup's are loading quite slow.

for example

http://www.allesvoordekeuken.nl/catalog/pr...products_id=647

 

I thought server caching might help but if I switch it on pictures are not shown anymore. I created the "thumbnails" folder under the images folder, CHMOD 777, in admin I set "/thumbnails" at thumbnail cache directory but it doesn't work.

 

I can see that thumbnails are created in \catalog\images\thumbnails\images. I guess the last images folder is created under the thumbnails folder by the contrib. However, pictures are not shown with the server cache option set to true.

 

Any suggestions??

Edited by mssmit
Link to comment
Share on other sites

Hi

First of all thanks for this awesome contrib!

 

It works very fine execpt the popup's are loading quite slow.

for example

http://www.allesvoordekeuken.nl/catalog/pr...products_id=647

 

I thought server caching might help but if I switch it on pictures are not shown anymore. I created the "thumbnails" folder under the images folder, CHMOD 777, in admin I set "/thumbnails" at thumbnail cache directory but it doesn't work.

 

I can see that thumbnails are created in \catalog\images\thumbnails\images. I guess the last images folder is created under the thumbnails folder by the contrib. However, pictures are not shown with the server cache option set to true.

 

Any suggestions??

 

 

Try creating the thumbnails directory under you store's root.

Tom

Edited by tomjmul

OSC Image Magic

On-the-fly thumbnails, watermarks and image processing

Link to comment
Share on other sites

question sounds a bit silly but I thought that the root folder for this item was already catalog/images, so if I have to link to a new folder "thumbnails" under the shops root folder, how can I set that properly?

 

 

Just create the folder under your store's root directory and put thumbnails/ into the box (actually this is the defualt.

 

Tom

OSC Image Magic

On-the-fly thumbnails, watermarks and image processing

Link to comment
Share on other sites

Tom & everyone else...

 

Great Contribution/ Tool, but two questions:

 

1. Is there a way to make it so that on the product_info.php page that the "Product Information Image Height" and "Product Information Image Width" does not enlarge greater than the uploaded pictures true dimensions?

 

2. Any update on the animated gif detection code so that animated GIF files still work?

 

Thanks,

 

Nate

Link to comment
Share on other sites

Tom & everyone else...

 

Great Contribution/ Tool, but two questions:

 

1. Is there a way to make it so that on the product_info.php page that the "Product Information Image Height" and "Product Information Image Width" does not enlarge greater than the uploaded pictures true dimensions?

 

2. Any update on the animated gif detection code so that animated GIF files still work?

 

Thanks,

 

Nate

 

Sorry. I found the answer to my first question.

 

For those who would like to do this also, Tom has made it very easy for us. Here is what you need to do:

 

Admin ---> Configuration ---> Image Magic ---> Allow thumbnails larger than original ---> FALSE

Link to comment
Share on other sites

I guess this contribution just won't work for me :( Pictures don't show and now my categories are also gone. Not sure if it had to do with cache or by having installed bts contribution. Error when copying from the image properties link directly into the browser : Fatal error: Call to undefined function: fail() in /imagemagic.php on line 28... I will give it 1 more day before I reset everything back. Anybody?

Livejapan

Link to comment
Share on other sites

I guess this contribution just won't work for me :( Pictures don't show and now my categories are also gone. Not sure if it had to do with cache or by having installed bts contribution. Error when copying from the image properties link directly into the browser : Fatal error: Call to undefined function: fail() in /imagemagic.php on line 28... I will give it 1 more day before I reset everything back. Anybody?

Livejapan

 

Bullshit !! :D Of course it will work for you

 

The problem you describe is actually quite minor. It looks like a problem with your database script import.

re-read the readme and try again.

 

Tom

OSC Image Magic

On-the-fly thumbnails, watermarks and image processing

Link to comment
Share on other sites

Bullshit !! :D Of course it will work for you

 

The problem you describe is actually quite minor. It looks like a problem with your database script import.

re-read the readme and try again.

 

Tom

Thanks Tom, I indeed found something I overlooked but still getting same error : on the server I'm using all tables are named started with oscommerce (so for example oscommerce_configuration). Now I changed in the imagemagic.php file following. Is there more to change as far as you know?

//connect to database and get all config values

$dbconn=@mysql_connect($server,$user,$password) or fail(10);

@mysql_select_db($dbname,$dbconn) or fail(20);

$sql="select configuration_key as cfgKey, configuration_value as cfgValue from oscommerce_configuration where oscommerce_configuration_group_id='333' or oscommerce_configuration_group_id='4'";

 

and

 

//have the config vars changed

if ($append_hash != LAST_HASH){

$sql="update oscommerce_configuration set configuration_value ='".$append_hash."' where configuration_key='LAST_HASH'";

$result=@mysql_query($sql,$dbconn) or fail(30);

Link to comment
Share on other sites

Hi!

 

I recently installed the Image Magic contribution, and I must say I was stunned to see that such a powerfull contribution was so easily installed, and so user friendly. Why couldn't all contributions be like this one...

Although it was easily installed, I must have done something wrong. Now, almost no image are shown on the site, and all the paths are like this:

 

http://ewis.no/shopping/imagemagic.php?img...=97&h=100&page=

 

I installed Additional Images (http://www.oscommerce.com/community/contributions,1032/category,all/search,additional+images)

, but I don't think it worked before I installed Image Magic. I'm pretty fresh in this game....

 

What should I do?

 

Our store: www.ewis.no/shopping/index.php

 

 

Thanks,

Fred St?yva

Norway

Link to comment
Share on other sites

Hi!

 

I recently installed the Image Magic contribution, and I must say I was stunned to see that such a powerfull contribution was so easily installed, and so user friendly. Why couldn't all contributions be like this one...

Although it was easily installed, I must have done something wrong. Now, almost no image are shown on the site, and all the paths are like this:

 

http://ewis.no/shopping/imagemagic.php?img...=97&h=100&page=

 

I installed Additional Images (http://www.oscommerce.com/community/contributions,1032/category,all/search,additional+images)

, but I don't think it worked before I installed Image Magic. I'm pretty fresh in this game....

 

What should I do?

 

Our store: www.ewis.no/shopping/index.php

Thanks,

Fred St?yva

Norway

 

At risk of repeating myself (about a million times :D ) You need to manually create a thumbnails folder in your store's root directory and chmod it to 777

 

Tom

OSC Image Magic

On-the-fly thumbnails, watermarks and image processing

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...