Menu Content

Currencies Accepted


Shopping Cart

cart
Your Cart is currently empty.

How to Download A Product

For most of our products, including the free ones, you will need to go through checkout and place an order.

Read More

 

Find Us Elsewhere

Follow us on Twitter

Spiral Scripts on Facebook

rapidssl_ssl_certificate
2Checkout.com is a worldwide leader in payment services
Home » Forum

Welcome, Guest

Imgen watermark problem if spaces in filename
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Imgen watermark problem if spaces in filename

Imgen watermark problem if spaces in filename 5 months, 3 weeks ago #338

  • chris clay
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0
Hi!

Thanks for a great extension. I'm using Imgen with the watermark plugin, and hacked a few other extensions so they will display the watermarked images. I've run into one problem, though, and I'm hoping someone will have an idea as to how to fix it.

My client has 1,000+ K2 articles, many of which have photo galleries. Unfortunately most of the photo file names have spaces in them, like this: "One Harbourgreen Place - 1169 W. Cordova 2.jpg"

The K2 articles use Simple Image Gallery Pro to display the images, and it replaces the spaces with "%20". This works fine when displaying the original images in a lightbox, but not the watermarked ones.

Here's a sample of an URL generated by the Gallery plugin:

http://www.clientdomain.com/media/k2/galleries/28/Carina%20-%201233%20W.%20Cordova%201.jpg


It displays fine.

When the same URL is modified to display the watermarked version (also using %20 instead of spaces) the watermark plugin doesn't work. Here's a sample of a modified URL:

http://www.clientdomain.com/index.php?option=com_imgen&img=http://www.clientdomain.com/media/k2/galleries/28/Carina%20-%201233%20W.%20Cordova%204.jpg&format=image


Any gallery without a space in the filename loads fine... Any idea as to what I can do to help the plugin work with these spaced filenames? Unfortunately there are hundreds of images, each in their own gallery folder, so renaming them to remove the spaces is not an option.

Cheers,
Chris
Last Edit: 5 months, 3 weeks ago by chris clay.

Re: Imgen watermark problem if spaces in filename 5 months, 3 weeks ago #339

  • chris clay
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0
P.S. If I manually rename an image, it displays fine - here's an example of a working watermarked URL:

http://www.clientdomain.com/index.php?option=com_imgen&img=http://www.progressivevancouver.com/media/k2/galleries/28/carina.jpg&format=image
Last Edit: 5 months, 3 weeks ago by chris clay.

Re: Imgen watermark problem if spaces in filename 5 months, 3 weeks ago #340

I will have a look at this, hopefully there is a solution. But none of the urls you supplied work, I just get a 404 component not found error.

Re: Imgen watermark problem if spaces in filename 5 months, 3 weeks ago #343

  • chris clay
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0
Thanks Susan.

No, the links don't work - I substituted the client's real domain name with "www.clientdomain.com" in the sample links (since the site isn't public yet and the client wants to keep it private until it's officially launched.)

Regards,
Chris

Re: Imgen watermark problem if spaces in filename 5 months, 3 weeks ago #344

  • chris clay
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0
Hi Susan,

I installed Imgen and the watermark plugin on another site and was able to easily reproduce the problem. I simply uploaded an image with spaces in the name and then tried to use Imgen as usual to create the watermarked version.

Here are some live, working links that you can test:

Image name:
facebook 180 540.gif (note the spaces)

Working link:
http://74.54.218.82/~comm/images/facebook%20180%20540.gif


Watermarked version, not working:
http://74.54.218.82/~comm/index.php?option=com_imgen&img=http://74.54.218.82/~comm/images/facebook%20180%20540.gif&format=image


Even though I'm passing a valid source link via the "&img=..." parameter, Imgen can't handle it for some reason. I know that spaces in file names isn't a good idea in general, but obviously many sites have inexperienced users who don't know any better. Since other plugins can still work with the same images (such as Simple Image Gallery Pro) I'm sure there's a solution but it's beyond my PHP skills Maybe an image with spaces in it could be automatically copied to a new file that has underscores instead of spaces?

Cheers,
Chris
Last Edit: 5 months, 3 weeks ago by chris clay.

Re: Imgen watermark problem if spaces in filename 5 months, 3 weeks ago #348

  • chris clay
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0
A friend of mine was able to solve this problem by remarking out a line of code. All the watermarked images on my client's site now display perfectly, even the ones with spaces in the filenames I'll paste his entire response below in case anyone else needs it in future. Perhaps this line could be removed from the next version of Imgen (or at least kept in but revised somehow.)

Cheers,
Chris

After some messing around, I think I solved the problem by remarking out a line of code in ...

/public_html/components/com_imgen/helpers/imgen.php

... at line number 35.

//$img = str_replace(' ','%20',$img);

What the line does is replace spaces in the image file name with "%20" ... which had been replaced
with spaces earlier on in the logic stream. Go figure.

It was breaking the code by then passing the modified image name to a size-deducing routine
that was choking on the "%20"

Story is, if you are referring to an image via http, then spaces need to be encoded as "%20"
but if you are referring to an image via the command line, then spaces should be passed
along as is.

It seems strange then that line 35 would encode spaces just before passing the file name
to a routine that chokes on encoded spaces.

Hopefully remarking out this line won't cause problems downstream. It may be that we'll need
to re-encode the spaces after the size-deducing routine has done its thing.

Re: Imgen watermark problem if spaces in filename 5 months, 3 weeks ago #349

Thanks for this - the thing is that the official PHP manual says that spaces should be encoded as '%20' when using the getimagesize() function, but I think you are right, this is only when the image path is a full url rather than a physical path. I have noticed before that it causes problems then.

It should not be difficult to put this right in a new release.
  • Page:
  • 1
Time to create page: 1.16 seconds
 
 

VirtueMart Featured Products Grid

Switch View

This module displays a short excerpt from articles in a selected category or section, or from a specified list of articles, with link and optional thumbnail image.

£12.00


A Flash puzzle game for the Joomla! content management system. This would be suitable for a site aimed at children.

£12.00


This module displays a short excerpt from articles in a selected category or section, or from a specified list of articles, with link and optional thumbnail image.

£14.00


A module extension for the the Joomla CMS. It plays a random list of mp3s using the Flash media player.

£12.00