Jump to content



Photo
* * * * * 3 votes

[Contribution] oscThumb


  • Please log in to reply
443 replies to this topic

#1   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 24 October 2007 - 09:08

Hello all,

oscThumb is a contribution that uses the open source project phpThumb v1.7.7 to create thumbnails of your images.

Instead of sending the full size image to the browser and let the browser resize it, which can seriously slow down the loading time of your pages and look ugly, oscThumb will generate thumbnails and save them in a cache folder on your server, for future use.

It uses Imagemagic (if available) or GD library to generate gif, jpg or png thumbnails.
In my knowledge, this is the only thumbnailing contribution that can really protect your images agains thieves!

Following features are included:

Server caching: thumbnails created are saved on the server, no need to re-generate them for each visitor. Automatic cache cleaning function included (size, age, nbr of files).
Watermarking: place a text or image watermark on your images to protect them from thieves.
Security against URL manipulations: filenames encryption make it impossible to find the original image and URL hash check make it impossible to manipulate URL to display images in original size.
Display options: add a frame around your images or buttonize them. New size for product image on product_info.php page, selectable from admin.
Easy installation: few files to copy, 3 files to modify. Done.

I give you soon the link to the contribution, when it's out of the sandbox.

I'm using this contribution with success on few sites already.

Have fun,

Chris
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.

#2   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 24 October 2007 - 16:08

All right, contribution is now available in the contribution section: http://www.oscommerc...tributions,5491.

Comments and questions are welcome.
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.

#3   jeebus

jeebus
  • Members
  • 24 posts
  • Real Name:Dave

Posted 25 October 2007 - 03:39

I can't believe I stumbled across this and installed thinking it's been out forever. /biggrin.gif' class='bbc_emoticon' alt=':D' />

I just noticed this post when looking for answers to my problems.

Anyways... here's my issues.

1. with the image watermark turned on the image comes up as normal. No watermark.
2. with the text watermark turned on I get an image just a green block with error: Invalid Hash
3. with the frame turned on the frame works

Also when I delete a product now I get this error:

1146 - Table 'comotors_p_os1.TABLE_ADDITIONAL_IMAGES' doesn't exist

delete from TABLE_ADDITIONAL_IMAGES where products_id = '69'

[TEP STOP]



Any help would be greatly appreciated.
Dave

Edited by jeebus, 25 October 2007 - 03:41.


#4   jeebus

jeebus
  • Members
  • 24 posts
  • Real Name:Dave

Posted 26 October 2007 - 00:04

Anyone?

#5   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 26 October 2007 - 06:13

This is a quite young contribution, I guess you are the first one to try it after me. I'm going to check again the watermark options. For the sql error, it's not related to this contribution, 100% sure.
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.

#6   demio

demio
  • Members
  • 1 posts
  • Real Name:Carlos Lage

Posted 26 October 2007 - 09:30

This is a quite young contribution, I guess you are the first one to try it after me. I'm going to check again the watermark options. For the sql error, it's not related to this contribution, 100% sure.



Hey man,

I see a lot of calls to constants in your class: CFG_MASTER_SWITCH, LAST_HASH, etc.

But I don't see them ever getting set. I'm getting problems with this since no single piece of configuration is being recognized.

I think this is what needs fixing. /thumbsup.gif' class='bbc_emoticon' alt=':thumbsup:' />

#7   jeebus

jeebus
  • Members
  • 24 posts
  • Real Name:Dave

Posted 26 October 2007 - 12:14

This is a quite young contribution, I guess you are the first one to try it after me. I'm going to check again the watermark options. For the sql error, it's not related to this contribution, 100% sure.



I figured that error wasn't completely part of this.. but I know I did not have this error before I made the changes to my files, so I was hoping you could tell me what I may have messed up and where?

As for the rest of the contribution... other then my issues above it works great. I love it, however I would like to have those features working as it's part of the reason I installed it.

Thanks.

#8   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 26 October 2007 - 13:43

For the sql error, you have to define your TABLE_ADDITIONAL_IMAGES constant into admin/includes/databases.php, like: define ('TABLE_ADDITIONAL_IMAGES', 'additional_images'), value depending of the real name of the table.

The constants you mentionned in the oscthumb class are the configuration parameters you see in admin. You won't see any define(.....) because all these parameters are automatically created in application_top.php .

I found a mistake in the installation sql file of this contribution, maybe it's the reason of your problems. Go to Admin > Configuration > Thumbnails, then change "Image Watermark Position" and "Text Watermark Position" to what you want. The default ("Top") value is not recognized, must be "T" once saved.

I have discovered few little bugs in my code as well as a new phpThumb version, so I'll release shortly a new version of this contribution.
Few bugs: cache cleaning not working correctly when using sub-directories (default) + black background on watermarked gif's + not working when using the includes/local/configure.php file.

I have fast tested this new phpThumb and seems to solve the watermarked gif's problem. I tried graphic + text watermark on same gif image: no problem. This new version has some new watermarking features (like graphic watermark scaling), but I'll not implement them right now in this contribution.

Also, I think that some features are useless (like watermarking heading images and small images), please comment. If nobody needs, I'll remove them.
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.

#9   jeebus

jeebus
  • Members
  • 24 posts
  • Real Name:Dave

Posted 26 October 2007 - 13:59

-No matter what position I put the image watermark it still does not work. Just shows the original image
-No matter what position I put the text watermark on it still gives the black(green) image with error: Invalid Hash


As for the need for the smaller watermarks.. I do not see a need for them.

#10   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 27 October 2007 - 07:34

Switch off the filename encryption (in admin, parameter "Encrypt Image Filenames" to False), and switch off the check of the hash in catalog/phpThumb/phpThumb.config.php (parameter "$PHPTHUMB_CONFIG['high_security_enabled']", so hash should not be a problem anymore. But I guess another problem will show up. Please post here the URL of your images, like it happears in the html code, it helps debugging.

- Chris
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.

#11   blagger

blagger
  • Members
  • 392 posts
  • Real Name:Asif Mohammed
  • Location:United Kingdom

Posted 27 October 2007 - 13:53

Does this contrib work fine with ssl and non ssl, just looking at a similiar contrib but someone is stating there is a problem with SSL.

#12   jeebus

jeebus
  • Members
  • 24 posts
  • Real Name:Dave

Posted 27 October 2007 - 14:06

Switch off the filename encryption (in admin, parameter "Encrypt Image Filenames" to False), and switch off the check of the hash in catalog/phpThumb/phpThumb.config.php (parameter "$PHPTHUMB_CONFIG['high_security_enabled']", so hash should not be a problem anymore. But I guess another problem will show up. Please post here the URL of your images, like it happears in the html code, it helps debugging.

- Chris




Alright with these changes made:

-text watermark works
-image watermark does not work

Here's a link to one of the images.. I think this is what you were looking for.

http://comotorsports...o...;h=400[]=wmt|CO Motorsports|20|C|000000|thalea.ttf|20|0|10&f=jpg&q=95&hash=f51e4f6ebda43167c558342ffc8bc5ad

#13   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 28 October 2007 - 08:50

Your link is broken due to this forum but I copy-paste and get your image. The link is for a text watermark and it works. I changed to image watermark and it does not work. I then took your image to my test shop and the image watermark is showing up. Have you tried to choose another watermark image from the admin? Which version of the GD library you have?
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.

#14   Frank Heinen

Frank Heinen
  • Members
  • 212 posts
  • Real Name:Frank Heinen
  • Gender:Male
  • Location:The Netherlands (Aalten)

Posted 28 October 2007 - 19:12

Line 232 of includes/classes/oscthumb.php is setting the wrong directory link:
if ($image_watermark) {
$params .= "&fltr[]=wmi|watermarks/".WATERMARK_IMAGE."|".WATERMARK_IMAGE_POSITION."|".WATERMARK_IMAGE_OPACITY."|".WATERMARK_IMAGE_MARGIN;
}

For default directory it should be:

if ($image_watermark) {
$params .= "&fltr[]=wmi|phpThumb/watermarks/".WATERMARK_IMAGE."|".WATERMARK_IMAGE_POSITION."|".WATERMARK_IMAGE_OPACITY."|".WATERMARK_IMAGE_MARGIN;
}

For the next version a watermark directory definition (adjustable from the admin or defined in the config.php) would better.

#15   Frank Heinen

Frank Heinen
  • Members
  • 212 posts
  • Real Name:Frank Heinen
  • Gender:Male
  • Location:The Netherlands (Aalten)

Posted 28 October 2007 - 20:17

Another problem, in resizing images who are smaller then the requested image size.

Line 126 of includes/classes/oscthumb.php
if ($width > $image_size[0] || $height > $image_size[1]) {
should be:
if ($width > $image_size[0] && $height > $image_size[1]) {

Explaination:
If an image is smaller then the requested width but larger then the requested image height then it does need to be resized and limited to the
requested limits (note the height and width are maximum width and height). As it is now then it doesn't resize it.

Example:
Image height: 600 pixels
Image width: 100 pixels

Requested height: 120 pixels
Requested width: 120 pixels

Now it need to be resized to:
height: 120 pixels
width: 20 pixels

At the moment it doesn't resized it and shows the 600 x 100 pixel image.

#16   phpgirl

phpgirl
  • Members
  • 31 posts
  • Real Name:joel
  • Location:New York

Posted 28 October 2007 - 21:26

im very new to oscommerce...

I installed it and I got this error

Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory.

can anyone help me with this please


thanks

#17   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 29 October 2007 - 10:56

What version of osCommerce are you using? Have you just copied the contribution files over your installation? The files delivered with this contributions are for 2.2MS2 version, if you just copy over a 2.2RC1 you'll get this error. It is mentionned in the install instructions to do the changes manually and not overwrite if you have a 2.2RC1, which is at this date the latest version. The best would be to use a file-compare program to merge the changes (believe me, it'll save you millions of hours).
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.

#18   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 29 October 2007 - 11:19

@Frank:

Image watermark:
The watermark directory you see in the image URL is relative to the phpThumb directory, because phpThumb is executed there. Have you experienced problem with this? Maybe that's why Jeebus does not see his image watermarks, but then it means it depends on server configuration.

The directory can be moved to a parameter, why not.

Image size:

Another problem, in resizing images who are smaller then the requested image size.

Line 126 of includes/classes/oscthumb.php
if ($width > $image_size[0] || $height > $image_size[1]) {
should be:
if ($width > $image_size[0] && $height > $image_size[1]) {

Explaination:
If an image is smaller then the requested width but larger then the requested image height then it does need to be resized and limited to the
requested limits (note the height and width are maximum width and height). As it is now then it doesn't resize it.

Example:
Image height: 600 pixels
Image width: 100 pixels

Requested height: 120 pixels
Requested width: 120 pixels

Now it need to be resized to:
height: 120 pixels
width: 20 pixels

At the moment it doesn't resized it and shows the 600 x 100 pixel image.

Well done, you are right there is something wrong here. Next version coming soon... with newer version of phpThumb, just need time to pack everything together again.
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.

#19   jeebus

jeebus
  • Members
  • 24 posts
  • Real Name:Dave

Posted 29 October 2007 - 12:10

I made the change noted above relating to the directory issue. That did not fix the issue. The image still just comes up as normal with no watermark.

#20   rigadin2

rigadin2
  • Members
  • 349 posts
  • Real Name:Chris
  • Gender:Male
  • Location:Helsinki/St-Petersburg

Posted 29 October 2007 - 13:08

About the code for the size (line 126 in oscthumb class v1.0.0):

Another problem, in resizing images who are smaller then the requested image size.

Line 126 of includes/classes/oscthumb.php
if ($width > $image_size[0] || $height > $image_size[1]) {
should be:
if ($width > $image_size[0] && $height > $image_size[1]) {

Explaination:
If an image is smaller then the requested width but larger then the requested image height then it does need to be resized and limited to the
requested limits (note the height and width are maximum width and height). As it is now then it doesn't resize it.

Example:
Image height: 600 pixels
Image width: 100 pixels

Requested height: 120 pixels
Requested width: 120 pixels

Now it need to be resized to:
height: 120 pixels
width: 20 pixels

At the moment it doesn't resized it and shows the 600 x 100 pixel image.


The code mentionned is for images smaller than asked: do we show them bigger or in their original size. The function asked by Frank is in case the image is bigger than asked, that's another story not covered by the class so far, but it would make sense to implement it.
STS v4.5 SP5 is out, and check the STS Power Pack contribution too!
New thumbnailer using phpThumb: oscThumb. Works great.