Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Contribution 2094 - Image resize


galen

Recommended Posts

  • Replies 133
  • Created
  • Last Reply

Top Posters In This Topic

Galen:

 

Thank you for taking on this project. I really appreciate your effort. Hopefully many other osCommerce user will also in the future.

 

I am going to install now using your excellant directions and I'll report back here.

 

Thank you again. I am grateful.

Link to comment
Share on other sites

Hello Galen:

 

Thanks again for working on this contrubution.

 

I get this error:

Parse error: parse error, unexpected T_STRING in includes/configure.php on line 26

 

This is line 26 of configure.php

define('DIR_WS_RSIMAGES' DIR_WS_IMAGES . 'res/');

 

If I move the line I get the same error put a different line #.

 

I have created the directory res under images and chmod it 777. I also tried changing <U>'res/');</U> to <U>'images/res/');</U> and same error.

 

I would bet this is a simple thing simple that I am overlooking in my haste to get this working but for the moment I am stumped. I'll keep trying but do you see something I am forgetting?

Link to comment
Share on other sites

Now I have noticed something else. The images that are being created in the res directory are the same size as the originals. They have been renamed but the same size.

 

Images are still not showing although the img src path appears to be correct. Please see this url for a comparision of the contribution installed and what the page should look like:

 

http://www.drabel.com/magick.html

Link to comment
Share on other sites

perhaps try turning on images even if there isn't one so you can see the broken image link.

 

Then you should be able to click properties and see what image it is trying to display..

 

Galen

Link to comment
Share on other sites

Hello Galen:

 

The place where you would normally see a broken image is only a tiny dot that I can not get properties from. However, when I view the page source the img src link is:

 

<img src="images/res/1633-82_1_1.jpg"

 

The image is there. But has not been reduced. It is the same size as the original. In addition, it is not showing up on the web page.

 

For those attemping this contribution in configure.php this line should be:

define('DIR_WS_RSIMAGES', DIR_WS_IMAGES . 'res/');

 

The , was left out of the original.

 

I think we are close to getting this to work. I appreciate your efforts Galen.

 

Suggestions?

 

Dennis

Link to comment
Share on other sites

Hi guys!

 

Thanks Galen for all your help so far. I installed this contribution per the instructions and now all of my images have disappeared. Even my logo in my header.

 

I reinstalled a fresh install of ms2.2 and tried again and still.. no image at all. Anyone know what I am doing wrong?? Here is my store:

 

http://ragabelle.com/bowtique/

 

Thanks in advance for any help. I have about 6 sites I need to get this working one.

 

Shanna

Link to comment
Share on other sites

Hi Dennis! :)

I am glad that at least it it doing something. I have tried several resize contributions and have yet to get any them to work. I had one other contribution that did this same thing. And then another that fixed the images in the admin area as well as the catalog area. Unfortunaltely only the admin area worked for me. I only need the catalog area to work.

 

If anyone has some insigt.. Please let me know. I have root access to the server, So I can change anything I need. ;)

 

Shanna

Link to comment
Share on other sites

I've installed the contribution and I have the same problem that "dennisra", the contribution makes the thumbs but with the same size (or higher) than the original image. I think the trouble is that mogrify.exe it's in the wrong place, and I don't understand this:

 

-install imagemagick and copy mogrify to your safemode path

 

Thank you

 

 

P.D: Sorry my english

Link to comment
Share on other sites

Mosaico:

 

This is what I have tried:

 

exec(DIR_IMAGEMAGICK . "/usr/local/bin/mogrify -geometry " . $width . " " . $filename_small);

 

Of course that hasn't worked for me either.

 

Hopefully when people get home from the Memorial Day weekend we will get a helpful response.

 

Dennis

Link to comment
Share on other sites

Hi Guys,

 

Sorry I haven't been around to reply, but oscommerce didn't send me a message saying there have been forum replys.. :(

 

Now, i've been having a look at mogify and I think you should have a read of this URL

 

http://ftp.fifi.org/ImageMagick/README.txt

 

Probably notice the bit about support for JPEG and other modules, if you don' thave support for these modules them mogify won't be able to process them.

 

What I suggest doing is that you get a JPG which you know the size of and try manually running mogrify.

mogrify man page - http://amath.colorado.edu/computing/softwa...n/mogrify.html)

 

EG.

 

To scale an image of a cockatoo to exactly 640 pixels in width and 480

pixels in height, use:

 

mogrify -resize 640x480! cockatoo.jpg

 

Try this, and if you get this kind of thing working you can then work on the webpage.

 

I'm still having a play around myself, will get bak when I know more.

 

Regards

Galen

Link to comment
Share on other sites

I've had a little more of a look into the programming and this is what the function does.

 

It copies the image from its original location and places it in the res directory, with an updated filename of the dimensions.

 

From there it runs the mogrify command. From what I see, the mogrify command does not have the librarys to convert over the image so it actaully does nothing leaving you with the same image.

 

When mogrify does work it overwrite the image with the correct sized image.

 

I did a few trials with .tiff, .png, .jpg and the only one that worked as it should was .png.

 

All the others came up this with error

 

mogrify: no decode delegate for this image format

 

This means that there is no library so you gotta get them and install them. A comprehensive list can be found at this address.

 

http://ftp.fifi.org/ImageMagick/README.txt

 

Hope this helps

Galen

Link to comment
Share on other sites

Well, after a little more playing around I got it all working.

 

These are the steps I went thru.

 

downloaded the jpg librarys and gif librarys (these are the only 2 formats I use)

 

recompiled these with imagemagick

 

added this fine to the start of the tep_image function

define('DIR_IMAGEMAGICK','/usr/local/bin/');

 

loaded up some pages and an image of 1974x857 was resized to 100x43, so the picture in the product description was nice and small, and when you clicked on it you got a friggen huge image :D

 

This contrib kinda makes thumbnails on the run, and will keep your dimensions.

 

Note: you can use convert/mogrify etc to change pictures to your liking add in text/watermarks.

 

Probably the biggest problem is getting the librarys for it.

 

All i can say is test it manually before implemting it in the webpage.

 

Regards

Galen

 

*Useful NOTE ;) : Delete all images from the res directory to get them to start creating again. Once created they will not re-create or modify the ones already in there.

Edited by galen
Link to comment
Share on other sites

Sorry for the many many posts.. but it won't let me edit my previous posts.. but a bit of reading for you guys ;)

 

my oscommerce webpage currently has it running, www.advisns.com.au

 

If you view a product you will see the re-sized image but if you click on the show larger image it will show the original image.

 

To test this on my web page view a product, right click on the image and click view image. You should then see an image which is resized(probably 100x80) then click on the image and you should see a much larger image.

 

Generally they are about 1/4 of the size of the full size image.

 

The people who I currently host with also had imagemagick already installed so it was an easy thing for me to implement (took a while longer when testing it on my home linux machine as you can see from the posts above)

 

If the place you host with does not have imagemagick installed perhaps try to ask them nicely or even try uploading it yourself but in doing this you will need to upload a couple of things, a couple which I know of are mogrify, libMagick.so.6(the library it calls), also any librarys used to resize.. these may also be compiled into the libMagick.so.6...

 

 

Good Luck

Galen

Link to comment
Share on other sites

Hi Galen,

Thanks for all of your hard work!! I have tried this contribution again in hopes that it woud work. Unfortunately it's just not working. :( When I update the html_output.php file, all of my images/icons disappear. It does not matter if they are gifs, jpgs, etc. Can someone post a clean html_output.php with these mods included so i can compare. Perhaps I am missing something. Or if anyone else has any suggestions, my ears are open. ;) I left the site as is for now.. here you can see.. no images.

 

Ragabelle Bowtique

 

Thanks in advance for any help.

 

Shanna

Link to comment
Share on other sites

Its possible you have defined DIR_WS_RSIMAGES incorrectly.

 

It may be trying to look for images but its looking in the wrong location.

 

If you don't already turn on disaply images even if there aren't any, so you can see broken links and where/if they are linked anywhere.

 

If Imagemagick isn't working you should still see the copied images, just not resized.

I'd b leaving towards something is incorrectly setup in your config, not in the function below, as its pretty much static.

 

from configure.php

define('DIR_WS_RSIMAGES', DIR_WS_IMAGES . 'resized/');

 

As for my html_output.php file, here is the snippet from the tep_image function from the catalog/includes/functions/html_output.php

 

function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '', $res = 1, $addattribs = 1){

define('DIR_IMAGEMAGICK','/usr/local/bin/');

if ((empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') || !is_file($src)) {

return false;

}

if ( !strstr($width, '%') && $res) {

$width = round($width);

$height = round($height);

preg_match("/.*\/(.*)\.(\w*)$/", $src, $fname);

list($oiwidth, $oiheight, $oitype) = getimagesize($src);

if (($width || $height) && ($height < $oiheight || $width < $oiwidth)) {

if (!$height) $height = 1;

if (!$width) $width = 1;

$k = max($oiheight / $height, $oiwidth / $width); //use smallest size

$width = round($oiwidth / $k);

$height = round($oiheight / $k);

// createthumb($filename, $width, $height, "test.jpg");

$filename_small = DIR_WS_RSIMAGES . $fname[1] . '_' . $width . '_' . $height . '.' . $fname[2];

if (!file_exists($filename_small)) {

copy($src, $filename_small);

exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $width . " " . $filename_small);

}

$src = $filename_small;

}

}

// alt is added to the img tag even if it is null to prevent browsers from outputting

// the image filename as default

$image = '<img src="' . tep_output_string($src) . '" border="0" alt="' . tep_output_string($alt) . '"';

 

if (tep_not_null($alt)) {

$image .= ' title=" ' . tep_output_string($alt) . ' "';

}

 

if ($addattribs && tep_not_null($width) && tep_not_null($height)) {

$image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';

}

 

if (tep_not_null($parameters)) $image .= ' ' . $parameters;

 

$image .= '>';

 

return $image;

}

Link to comment
Share on other sites

I have not changed anything in my configure.php file aside from adding these 2 lines:

 

define('DIR_WS_RSIMAGES', DIR_WS_IMAGES . 'res/');

define('DIR_IMAGEMAGICK', '/usr/bin/');

 

When I put the old default html_output.php file back in place, my images show up like so:

 

Ragabelle Bowtique

 

my server meets all of the requirements AFAIK:

 

phpinfo

 

The thing is I have 6 diff sites on my server using oscomm and this does not work on any of them. :(

 

Shanna

Link to comment
Share on other sites

Have you got the correct permission on the res directory? (chmod 777)

 

As the script just copies the picture to the res directory then changes it from there.

 

Like I was saying above if the pictures are copied there but they haven't been resized then everything is working except mogrify.

 

Something which I do quite often is echo varables thoughout the function (eg echo $src) to see how far or were it gets.. or even if it even uses the function. Sometimes I create an error on purpose to see if it gets read.. as sometimes echoing doesn't work(if it redirects at the end of the function.. generally called via tep_redirect)

 

Regards

Galen

Link to comment
Share on other sites

Have you got the correct permission on the res directory? (chmod 777)

 

yep. Perms are fine.

 

As the script just copies the picture to the res directory then changes it from there.

 

Like I was saying above if the pictures are copied there but they haven't been resized then everything is working except mogrify.

 

I wish I could get the pics to at least copy there... then at least I would know it was mogrify. It seems weird thought that even my graphic in my header disappears... as well as icons, etc. They all vanish.. not even a red X.

 

Something which I do quite often is echo varables thoughout the function (eg echo $src) to see how far or were it gets.. or even if it even uses the function. Sometimes I create an error on purpose to see if it gets read.. as sometimes echoing doesn't work(if it redirects at the end of the function.. generally called via tep_redirect)

 

And this is where I am getting in over my head. LOL. I am not sure where/how to insert an echo statement. Any help would be very grateful. Thanks.

 

Shanna

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.

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...