Jump to content

imagejpg question


badzv

Recommended Posts

hi guys...got some questions regarding on my script....

[code]<?php

error_reporting(0);

$w = (int)$_POST['width'];
$h = (int)$_POST['height'];

$img = imagecreatetruecolor($w, $h);

imagefill($img, 0, 0, 0xFFFFFF);

$rows = 0;
$cols = 0;

for($rows = 0; $rows < $h; $rows++){

$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){

$value = $c_row[$cols];

if($value != ""){

$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}

$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));

$test = imagecolorallocate($img, $r, $g, $b);

imagesetpixel($img, $cols, $rows, $test);
}
}
}

header("Content-type:image/jpeg");

imagejpeg($img, "", 95);

?>[/code]

...as you can see, the image comes from a POST variables. the problem here is that the image could be viewed but its not on the server. could somebody help me please how to make that image thats been generated with my php script to be on the server already? upon generated, it would be on the server already.

thank you very much!
Link to comment
https://forums.phpfreaks.com/topic/35561-imagejpg-question/
Share on other sites

Your question is not real clear.  By being on the server already do you mean save it to the server as a file?

If so, I got the following from HuggieBear in response to a question I posed.  This may not be the question you are asking.  If you are talking about how to get the image into a html page, well, I'm struggling with that also.

imagejpeg($im);
or

imagejpeg($im, null, 100);

By changing, or adding the second parameter, you can save the image.


$filename = '/home/domains/domain.co.uk/images/dynamic.jpg';
imagejpeg($im, $filename, 100);

Regards
Huggie
Link to comment
https://forums.phpfreaks.com/topic/35561-imagejpg-question/#findComment-168477
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.