yakseller Posted June 3, 2004 Share Posted June 3, 2004 I really like this contribution, thank you. One quick question, couldn't this code: 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; } } be changed to this: if ( !strstr($width, '%') && $res) { $width = round($width); $height = round($height); preg_match("/.*\/(.*)\.(\w*)$/", $src, $fname); if (!file_exists($filename_small)) { 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]; copy($src, $filename_small); exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $width . " " . $filename_small); } $src = $filename_small; } } Quote Link to comment Share on other sites More sharing options...
yakseller Posted June 3, 2004 Share Posted June 3, 2004 Good contribution thanks. Has anyone been able to get this to work to display pictures on admin/categories.php? Or in the admin section in general? Quote Link to comment Share on other sites More sharing options...
galen Posted June 4, 2004 Author Share Posted June 4, 2004 Hi Yakseller, For the admin section, i kinda looked at it and i'm sure you have read my notes in the config files.. but it isn't really a proeity for me... so i kinda left it alone. The problem occours when its looking for images.. i'm sure i could get it working now as i had to mod a little more code to convert it from /catalog/images to http://url/catalog/images.. The problem with the admin section is you need it to goto direct links.. Heres a little bit of code that mite help for the admin when placed at the top.. its a little expanded as my regexps skills aren't that great $exacturl=0; if (!is_file($src)){ $test=explode ("/", $src); $domain=explode ("/", HTTP_SERVER); if ($test[2]==$domain[2]){ $src=DIR_WS_IMAGES.$test['5']; $exacturl=1; } } then after the $src=$filename_small }} add in this if($exacturl==1){ $src = HTTP_SERVER.DIR_WS_HTTP_CATALOG.$src; } I use the above code for my html emails.. as it was linking to the non-resized images. As for your re-coding.. you are testing if a varable exists before it is defined($filename_small) so I wouldn't suggest using it. The resized image name needs to be worked out before it can been seen there. If the original images changes in size, it will put another image in there. If you change this line $filename_small = DIR_WS_RSIMAGES . $fname[1] . '_' . $width . '_' . $height . '.' . $fname[2]; to something like $filename_small = DIR_WS_RSIMAGES . $fname[1] . '_small' . '.' . $fname[2]; then all the resized images would be under the same name and you could define $filename_small before the if statement. Galen Quote Link to comment Share on other sites More sharing options...
galen Posted June 6, 2004 Author Share Posted June 6, 2004 Hi Shanna, Heres something to try.. Where the tep image function is... add this echo statement in.. After this line function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '', $res = 1, $addattribs = 1){ Add in echo $src; This will tell you if the function is being called, and if it is it will echo $src which will probably be along the lines of images/image.name.jpg This is probably the first step to see if the function is actually being called. Quote Link to comment Share on other sites More sharing options...
chnkiemnky Posted June 8, 2004 Share Posted June 8, 2004 OK.. now we are getting somewhere. The images are being called. I will leave the echo statement in so you can see: Ragabelle Bowtique So, what can I do next? I am sooooooo grateful for all of your help. Shanna Quote Link to comment Share on other sites More sharing options...
galen Posted June 8, 2004 Author Share Posted June 8, 2004 Hi Shanna, well this is a good sign.... now lets proceed to find how they are seeing them can you please paste to me your DIR_WS_IMAGES and tell me what your IMAGE_REQUIRED is set to.. you also can move the echo statement into this if statements if ((empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') || !is_file($src)) { echo $src; return false; } If you are seeing the /images/imagename still comment out that if statment by placing // in front of each line. Remember we are still playing.. this isn't a solution. Galen Quote Link to comment Share on other sites More sharing options...
chnkiemnky Posted June 9, 2004 Share Posted June 9, 2004 Hi Galen! Ok.. in my configure.php here is what the DIR WS IMAGES line says: define('DIR_WS_IMAGES', '/bowtique/images/'); Is that what you are looking for? The Image Required in my admin is set to True. I replaced the echo statement with the if statement you posted and I still see the same thing. You can see here: Ragabelle Bowtique I can comment this out if you want me to. Just LMK. And.. If i did somehting wrong... LMK. I can change stuff ASAP. Thanks Galen! Shanna Quote Link to comment Share on other sites More sharing options...
galen Posted June 9, 2004 Author Share Posted June 9, 2004 ok, the fact that you can still see this is bad.. eg why its not working probably whats happening is !is_file($src) isn't seeing it as a real file.. comment out that bit which I said in the previous post. You should see some kind of picutres then. then we will do some tests to see which of the following in that statment is causing the problems.. Galen Quote Link to comment Share on other sites More sharing options...
chnkiemnky Posted June 9, 2004 Share Posted June 9, 2004 OK, I commented out the If statement and it comes back to the original problem.... no pics including my graphic in my header, etc. :( Ragabelle Bowtique Shanna Quote Link to comment Share on other sites More sharing options...
galen Posted June 9, 2004 Author Share Posted June 9, 2004 Just for other users who have problems similar to shanna's make sure in your configure.php DIR_WS_IMAGES are defined correctly.. They should look like this... define('DIR_WS_IMAGES', 'images/'); define('DIR_WS_ICONS', 'icons/'); define('DIR_WS_RSIMAGES', DIR_WS_IMAGES . 'res/'); This ended up being the problem. Galen Quote Link to comment Share on other sites More sharing options...
chnkiemnky Posted June 9, 2004 Share Posted June 9, 2004 Thanks again Galen!!! You are the best! Shanna Quote Link to comment Share on other sites More sharing options...
galen Posted June 9, 2004 Author Share Posted June 9, 2004 This contrib now supports the admin section. Visit http://www.oscommerce.com/community/contributions,2094 for the info on how to implement this. Get the catalog side working before admin if you are installing from new. Galen Quote Link to comment Share on other sites More sharing options...
yakseller Posted June 9, 2004 Share Posted June 9, 2004 Instead of creating thumbnails at the same ratio as the larger images, is it possible to pad an image with white to make all thumbnails the same size? Thanks in advance... I tried messing with mogrify without too much luck. Quote Link to comment Share on other sites More sharing options...
yakseller Posted June 10, 2004 Share Posted June 10, 2004 I was able to do what I would like to do ay the command line by doing this: $convert -size 100x80 xc:white canvas.jpg $composite -gravity center input.jpg canvas.jpg output.jpg I tried incorporating it into the contrib unsuccessfully. Before these two lines, I rescaled the image using the same mogrify line in the contib. Thanks for any help in advance. Quote Link to comment Share on other sites More sharing options...
chrisstylez Posted June 10, 2004 Share Posted June 10, 2004 is it possible to use the GD library 2x with this contribution? or is it limited to only IMAGEMAGICK, becuase i can't get this to work for the life of it. Quote Link to comment Share on other sites More sharing options...
Olzen Posted June 10, 2004 Share Posted June 10, 2004 I have now read the whole topic... But I still have problems.. There is now pictures showing up on my page.. But in my images/res/ directory there is alot of new picture files... But why dosn't their show up on the page... My configure.php: define('DIR_WS_IMAGES', 'images/'); define('DIR_WS_RSIMAGES', DIR_WS_IMAGES . 'res/'); define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/'); define('DIR_IMAGEMAGICK', '/usr/bin/'); It is producering the pictures but not showing them ?? Anyone have a solution on this problem ? Quote /Olzen Link to comment Share on other sites More sharing options...
chrisstylez Posted June 10, 2004 Share Posted June 10, 2004 can someone tell me how to configure ImageMagic on a virtual web server. I have shared hosting. i found a guide for installing it without root access, but i need it in laymans terms lol im not familiar with SSH at all http://www.photopost.com/magicknoroot-php.html Quote Link to comment Share on other sites More sharing options...
galen Posted June 11, 2004 Author Share Posted June 11, 2004 ok, chrisstylez, is it possible to use the GD library 2x with this contribution? or is it limited to only IMAGEMAGICK, becuase i can't get this to work for the life of it. yes it is possilbe to use other image librarys/programs. All you need to change is this line.. exec(DIR_IMAGEMAGICK . "mogrify -geometry " . $width . " " . $filename_small); all that does is excute mogrify ... like you were using a command line so you can change it to other programs. you may already find that imagemagick is installed in /usr/bin or /usr/local/bin yakseller $convert -size 100x80 xc:white canvas.jpg if that is the command you used.. then its wrong.. you need to use this.. exec(DIR_IMAGEMAGICK . "convert -size 100x80 xc:white . " $filename_small. " "); Olzen Have a look at the source and see if its actaully putting the image tag in there.. If its not then its not finding the image files.. all looks good with your define statements. Also make sure that the /res/ directory has the re-sized images in there as the function copies the original image then re-sizes. Also place and echo statment at the end of the tep_image function to check that its calling it and you can check the results of the function as it progresses throught. sorry for the rushed respone guys.. if you can't make sence just re-post :) gotta run.. Galen Quote Link to comment Share on other sites More sharing options...
Olzen Posted June 11, 2004 Share Posted June 11, 2004 It is a little bit embarrassing, but the only thong I did to get it to work was change 1 to 100... :-) if (($width || $height) && ($height < $oiheight || $width < $oiwidth)) { if (!$height) $height = 100; if (!$width) $width = 100; Quote /Olzen Link to comment Share on other sites More sharing options...
visualpeople Posted June 14, 2004 Share Posted June 14, 2004 This is a great conrib and I have it working perfectly (at least I haven't noticed any problems yet) but in the description it mentions it's possible to make this watermark your images as well. Anyone tried this yet? A quick search of the imagemagick.org website yeilds no results on watermarking but I was thinking of trying to tackle this... I'm just not exactly sure where to start. -Ryan Quote Link to comment Share on other sites More sharing options...
Dennisra Posted June 14, 2004 Share Posted June 14, 2004 Ryan: What is your URL? I would like to see the contribution in action. Quote Link to comment Share on other sites More sharing options...
visualpeople Posted June 15, 2004 Share Posted June 15, 2004 I just created a visitor login to show you, so there are only a couple of photos on it. But you should get the idea of how it's working. The url is www.karlmaasdam.com/catalog The login is test and password is test1 -Ryan Quote Link to comment Share on other sites More sharing options...
Dennisra Posted June 15, 2004 Share Posted June 15, 2004 Ryan: Sorry to disappoint you but resize is not working. It is copying an image to your res directory but the image is exactly the same size as your original. You can verify this by right clicking on the thumbnail and choose view image. If it were working you would then see a small resized image. Instead you are viewing the original size photo. Quote Link to comment Share on other sites More sharing options...
galen Posted June 15, 2004 Author Share Posted June 15, 2004 Ryan, Dennisra is correct the resize is not working. This is directly related to imagemagick, either its not installed or you haven't defined IMAGEMAGICK_DIR to the correct location. As for the watermarks have a look at this page. http://www.cit.gu.edu.au/~anthony/graphics...tating/#overlay Remember only the thumbnail picture is changed, the original image(the click to see larger image) is not changed. Regards Galen Quote Link to comment Share on other sites More sharing options...
visualpeople Posted June 15, 2004 Share Posted June 15, 2004 Thanks to both of you -- I just assumed since I didn't get any error messages (which I have before with other programs when the path to ImageMagick was wrong) that it was all working correctly. I guess it was just my imagination that the pages seemed to load faster as well. Goes to show you what assuming makes me... It's all working now, thanks. -Ryan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.