Zubrag.com
July 17, 2018, 03:53:10 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Thumbnail Questions  (Read 26821 times)
Things
Newbie
*
Posts: 3


« on: December 04, 2006, 03:58:47 PM »

Hi, first I would like to thank you for such a short and easy to understand script.  I have used it together with retrieving photo file names from my database and thumb it to three different sizes for use throughout the database.  example
<img src=http://www.my site.com/data/thumb2.php?src=images/".$file['photo']."&x=400&y=400&f=0>

I have however a problem uploading to my server even with a simple script such as:
http://www.my site.com/thumb.php?src=foto1.jpg&dest=test.jpg&x=50&y=50
I recieve the message
"Warning: imagejpeg() [function.imagejpeg]: Unable to open 'test.jpg' for writing in /www/doc/www.my site.com/www/thumb.php on line 109"

If I try
http://www.my site.com/thumb.php?src=foto1.jpg&dest=thumb/test.jpg&x=50&y=50
I recieve the message
I simply receive a blank page and the file is not uploaded although foto1.jpg is in the root with my 'thumb ' folder. 

I would also like to know if my src could be on my local drive.  I would appreciate any help that you could offer.  Thanks

Logged
zubrag
Administrator
Hero Member
*****
Posts: 787


WWW
« Reply #1 on: December 04, 2006, 05:20:47 PM »

Please try downloading thumbnail creator again.

Now it allows to setup folder to save thumbnails. This means you do not need to provide path in the dest parameter. Just put destination file name, and script will save thumb into thumbnails folder you setup in settings.

I would also like to know if my src could be on my local drive.
Source file must either reside on the same server with thumb.php, or it should be available online, via http link.

Lets assume:
- you set thumbnails folder to /www/doc/www.mysite.com/www/thumbs/
- your big images are stored in /www/doc/www.mysite.com/www/images/
- you saved thumb.php in /www/doc/www.mysite.com/www/thumb.php

and you run script like this:
http://www.mysite.com/thumb.php?src=images/foto1.jpg&dest=test.jpg&x=50&y=50

script would look for the foto1.jpg in the images/ folder, and would save thumbnail as test.jpg in the thumbs/ folder.

if you run it like this (note no images/ in the src parameter)
http://www.mysite.com/thumb.php?src=foto1.jpg&dest=test.jpg&x=50&y=50

then script would look for foto1.jpg in the folder where you saved thumb.php, i.e. /www/doc/www.mysite.com/www/
Logged
Things
Newbie
*
Posts: 3


« Reply #2 on: December 05, 2006, 02:57:35 AM »

Thanks for the quick response.  I now have no problem uploading the images from and into any folder we want.

I am still going to try a way to upload the full image including my DB info and then resize the image and destroy the original full image.  Do you have any helpful ideas or tips?

Thanks again
Logged
zubrag
Administrator
Hero Member
*****
Posts: 787


WWW
« Reply #3 on: December 05, 2006, 03:18:16 AM »

I think if you specify same file name for src and dest then it will overwrite original image with its thumbnail. Did not try it though.

Something like:  thumb.php?src=images/".$file['photo']."&dest=".$file['photo']."&x=50&y=50
Logged
Things
Newbie
*
Posts: 3


« Reply #4 on: December 05, 2006, 05:54:05 AM »

Hey guy, your a genius, worked like a charm.  Thanks a whole lot.
Logged
ekuasita
Newbie
*
Posts: 1


« Reply #5 on: November 02, 2007, 10:18:57 PM »

I still have a problem for saving the thumbnail to specific folder on server.

When I try to run the script :

http://mysite.com/thumb.php?src=photo.jpg&dest=test.jpg&f=0

The thumbnail is shown in the browser.

But when I try to set f=1 (instead of showing the thumbnail, it will save to the spesific folder that I've set in the script)
then it show the message :

Unable to open '/home/mysite.com/public_html/fotothumb/test.jpg' for writing in (fotothumb is my thumb folder on server).

Also,

when I run the script by <img src="http://mysite.com/thumb.php?src=photo.jpg&dest=test.jpg&f=0"> , it show nothing.

How to resolve this problem

Thank's for your help.
Logged
zubrag
Administrator
Hero Member
*****
Posts: 787


WWW
« Reply #6 on: November 05, 2007, 07:07:07 AM »

Hi. Does 'fotothumb' folder have write permissions set? I suspect script cannot write to the folder.
Logged
cherlee
Newbie
*
Posts: 5


« Reply #7 on: November 13, 2007, 08:25:11 AM »

Hello,

I am building a simple CMS for a website. So for some sections, I want to help the user not to get into image manipulator like Adobe Photoshop for resizing images. Thus, I want to use this thumbnail generator for that purpose.
So the logic is somewhat like this :
When updating or adding a record on a database which requires an image, a larger image will be uploaded, the database will be manipulated and a thumbnail is generated.

But for some reasons, I don't know why but the script rejected the file type.
It said "Image type not supported" meanwhile I used .jpg for the image.

And after some editting, new error came out. This time "Cannot create temp file".

I am hopeless into editting the PHP since my knowledge of PHP is very limited.
Is there any tutorial? I mean, where in the script I must edit.
Some said that the $image_folder and $thumbs_folder should be emptied.
I think I need such tutorial to make the script works.
I am hopeless since I have been in this thumbnail generating for a week and no result so far.

Thank you.
Logged
zubrag
Administrator
Hero Member
*****
Posts: 787


WWW
« Reply #8 on: November 13, 2007, 08:36:18 AM »

There are few jpeg formats. It could be GD library included in php does not support some of them, or image size is too big to load into memory allowed for the script. Please send me the image to zubrag a*t zubrag.com for analysis.
Logged
cherlee
Newbie
*
Posts: 5


« Reply #9 on: November 14, 2007, 12:11:27 AM »

I have sent you the images.
Please check.
Thank you Smiley
Logged
zubrag
Administrator
Hero Member
*****
Posts: 787


WWW
« Reply #10 on: November 14, 2007, 04:46:19 AM »

Hi.

"dest" parameter is ignored when using f=0 (i.e. generating thumbnail directly to the browser)
So this
<img src="http://mysite.com/thumb.php?src=photo.jpg&dest=test.jpg&f=0">
will become
<img src="http://mysite.com/thumb.php?src=photo.jpg&f=0">

Looks like thumbnails cannot be saved on the server into fotothumb folder because this folder does not have permissions for writing.
Set write permissions on the folder and it should work (if your control panel is cPanel, then in File Manager, when you click on the folder, it would show permissions box in the top right corner).
Logged
cherlee
Newbie
*
Posts: 5


« Reply #11 on: November 15, 2007, 04:05:23 AM »

if I do not specify f parameter, the default value is 1, isn't it? I checked on the source. It should be like that.

And I have already changed the folder's permission into 777 before testing the script.

CAPTCHA script works but this one does not so I want to know why.
I read on your guestbook there were several people experiencing the same error with me.
Another solution?
Logged
zubrag
Administrator
Hero Member
*****
Posts: 787


WWW
« Reply #12 on: November 15, 2007, 05:32:47 AM »

Sorry cherlee, i was looking at the ekuasita's post while replying.

Are you generating thumbnails from urls? i.e. you put URL as "src" parameter? Are images located on different server than thumbnail script?
If images located on the same server where you have thumb.php then using URL as "src" would significantly slow down process. In this case you should define images and thumbnails folder, pass just image filename as parameter.
For example you have images and thumbnails folders set as follows:
$images_folder = '/home/example.com/public_html/images/';
$thumbs_folder = '/home/example.com/public_html/thumbs/';

http://example.com/thumb.php?src=photo.jpg&f=0 --- to show thumbnail in the browser
http://example.com/thumb.php?src=photo.jpg&dest=test.jpg --- to generate thumbnail from the image and save on the server

If images are indeed located on another server

When URL is passed as "src", script tries to load the image from that url on your server, in temporal folder, using this code:

$tmpfname = tempnam("tmp/", "TmP-");

Here "tmp/" defines the temporal folder name. PHP documentation states it should create file in system's default temporal folder if incorrect temporal folder specified. Looks like this is not working in your case.

So  you could create some folder on your server, and have script to use that folder. Lets say you have created /home/example.com/public_html/tmp3434/

then change code as follows
$tmpfname = tempnam("/home/example.com/public_html/tmp3434/", "TmP-");
Logged
cherlee
Newbie
*
Posts: 5


« Reply #13 on: November 16, 2007, 07:59:33 AM »

Ah, sorry.

Hmm.. I do not know if this case is indeed in the same folder, but I am trying to upload an image and make it into a thumbnail.
So, another PHP script is made to upload this image from my computer, manipulate the database, and call thumb.php to create the thumbnail.
Is it called as at the same server?

Well, I have editted the script as if they are in the same server and I have changed the $image_folder into '/home/something.com/public_html/images/'.$_GET['subfolder'].'/';
and so the $thumbs_folder
1 question about this, is it correct not to put the "www" before "something.com" or I have to use "www" ? I am not used with this kind of URL.

Well, after editting the script into what you told me and having my script to call thumb.php as :
http://www.something.com/admin/thumb.php?cat=news&src=news1.jpg&dest=news1-thumb.jpg&f=1&x=71&y=51

Nothing came out.
What happened?
Or should I place the URL in HTML tag like f=0 ? well I just simply redirect my script to run thumb.php and redirect to a confirmation page.
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC