Salve a tutti,
ho necessità di caricare un'immagine da Form per poi salvarla in originale e in bianco e nero.
Ho trovato uno script per la conversione.
Se apro infatti convert.php?f=foto.jpg visualizzo la foto in bianco e nero. Funziona. Ma ho necessità di poterla copiare in una cartella assegnando un nome.codice:<?php $source_file = $_GET['f']; $im = ImageCreateFromJpeg($source_file); $imgw = imagesx($im); $imgh = imagesy($im); for ($i=0; $i<$imgw; $i++) { for ($j=0; $j<$imgh; $j++) { // get the rgb value for current pixel $rgb = ImageColorAt($im, $i, $j); // extract each value for r, g, b $rr = ($rgb >> 16) & 0xFF; $gg = ($rgb >> 8) & 0xFF; $bb = $rgb & 0xFF; // get the Value from the RGB value $g = round(($rr + $gg + $bb) / 3); // grayscale values have r=g=b=g $val = imagecolorallocate($im, $g, $g, $g); // set the gray value imagesetpixel ($im, $i, $j, $val); } } header('Content-type: image/jpeg'); imagejpeg($im); ?>
Ho provato conma non funziona. Mi date qualche suggerimento?codice:copy("convert.php?f=foto.jpg","fotoBW.jpg");
Grazie in anticipo.

Rispondi quotando