LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-02-2004, 02:26 AM   #1
richard22
Member
 
Registered: Apr 2001
Posts: 60

Rep: Reputation: 15
php createimage


Hello I wanting to resize uploaded jpgs and am using a sample code:

<?php

function resize_jpg($img,$w,$h){

$imagedata = getimagesize($img);

if ($w && ($imagedata[0] < $imagedata[1])) {
$w = ($h / $imagedata[1]) * $imagedata[0];
} else {
$h = ($w / $imagedata[0]) * $imagedata[1];
}

$im2 = ImageCreateTrueColor($w,$h);

$image = ImageCreateFromJpeg($img); //line 15

imagecopyResampled ($im2, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1]);

ImageJpeg($im2, $img, 100);

}

resize_jpg("img_1774.jpg",200,200);

?>

I get:
Fatal error: Allowed memory size of 8388608 bytes exhausted at (null):0 (tried to allocate 6816 bytes) in /srv/www/htdocs/whatswhere/test.php on line 15

I've tried many variations and can't figure out the problem, the file is 833.2kb. Is it some sort of php or apache config

Help or pointer much appreciated Richard
 
Old 09-02-2004, 01:00 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
It is a php error. Try increasing the "memory_limit" value in php.ini then restart apache and try again.
 
Old 09-03-2004, 12:37 AM   #3
richard22
Member
 
Registered: Apr 2001
Posts: 60

Original Poster
Rep: Reputation: 15
Many thanks, I increased from 8 to 20mb and that did the trick.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Are PHP session variables held in memory when you leave a PHP site? Locura Programming 11 11-16-2008 08:37 PM
php5 apache2 mysql4 don't work, php does not seem to read php.ini atom Linux - Software 5 03-24-2005 11:05 AM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
PHP -- How to execute a shell script from PHP using FTP functions?? zoonalex Programming 3 07-29-2004 11:51 AM
Updating php 4.3.1 from tar and keeping current php configuration with mandrake 9.1 mrjeep Linux - General 0 04-02-2003 07:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration