Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-20-2006, 01:05 AM   #1 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 150
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
Image Write Permissions

I'm putting together a form to submit images to my photo gallery, and also create thumbnails for those images. The image submission is working great. The images are placed in the correct folder, and data is being written to a mysql table just fine. The resized thumbnail however will not save, and I've changed permissions to all files associated to 777. Any ideas?

Warning: imagejpeg(): Unable to open 'http://myspace.avclan.net/gallery/images/thumb.jpg' for writing in /home/myusername/domains/avclan.net/public_html/myspace/admin/process_image.php on line 20


Code:
function createthumb($src_image_path, $max_width, $max_height) {
	$src_img = imagecreatefromjpeg($src_image_path);
	$src_x = imagesx($src_img);
	$src_y = imagesy($src_img);

	$dst_img = imagecreatetruecolor($max_width, $max_height);
	imagecopyresampled($dst_img, $src_img, 0, 0, ((x >= y)?(round(.5 * $src_x - $src_y)):0), ((y >= x)?(round(.5 * $src_y - $src_x)):0), 100, 100, min($src_x, $src_y), min($src_x, $src_y));

	imagejpeg($dst_img, "http://myspace.avclan.net/gallery/images/thumb.jpg");
		
}

edited to add:

I googled a bit more and found this: http://textpattern.com/faq/178/image...ng-a-thumbnail

Q. Warning: imagejpeg(): Unable to access images/2t.jpg in textpattern/lib/class.thumb.php

A. This error messages is probably caused by a bug in PHP 4.4.1. It’s listed as fixed in the PHP 4.4.2 changelog.


Hey Mike, get crackin' on that PHP upgrade!

I've tried every workaround I could find including creating the file first with "fopen", using "touch" turning safemode off before the imagejpeg() function and on again afterward. Nothing works. The permissions are fine because a blank thumb.jpg file is created with fopen. imagejpeg simply does not want to write to the server. The plus side is I know my code is working because I was able to write the image directly to the browser by changing the header content-type to image/jpeg. It seems like my only option here is to wait for a php upgrade and create thumbnails manually until then
__________________
Current Project

Last edited by Redline; 04-20-2006 at 02:03 AM.
Redline is offline   Reply With Quote
Old 04-20-2006, 08:43 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,487
sde is on a distinguished road
here is a snipped of code i use to create thumbs.
PHP Code:
list($width$height) = getimagesize($filename);

// get the pecent needed to reduce the image height to 56 pixels
$percent = (100 56 $height) * .01;

// set thumb size
$new_width $width $percent;
$new_height $height $percent;

// resample image
$image_p imagecreatetruecolor($new_width$new_height);
$image imagecreatefromjpeg($filename);
imagecopyresampled($image_p$image0000$new_width$new_height$width$height);

$newfile "/path/to/images/gallery/".$image_id.".jpg";
move_uploaded_file($filename$newfile);
chmod($newfile0644);

$array explode(".",$name);
imagejpeg($image_p"/path/to/images/gallery/".$image_id."_t.jpg"); 
sde is offline   Reply With Quote
Old 04-20-2006, 10:07 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,487
sde is on a distinguished road
php has also been updated to 4.4.2.
sde is offline   Reply With Quote
Old 04-20-2006, 12:48 PM   #4 (permalink)
Redline
PHP Student
 
Join Date: Oct 2004
Location: Forest Grove, OR
Posts: 150
Redline is on a distinguished road
Send a message via AIM to Redline Send a message via MSN to Redline
Awesome, it's working now Thanks for the quick update Mike
__________________
Current Project
Redline is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
switch a .gif image in asp.net datagrid rikb53 MS Technologies ( ASP, VB, C#, .NET ) 0 02-17-2006 12:39 PM
Stationary Image joehouse HTML, XML, Javascript, AJAX 4 08-05-2005 07:03 PM
permissions saline Linux / BSD / OS X 7 05-24-2003 08:43 PM
I am a newb, how do you set multiple parts of an image as a link? I sniper baby HTML, XML, Javascript, AJAX 5 02-10-2003 06:40 PM


All times are GMT -8. The time now is 05:14 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting