get_file_by_hash( $filehash); $image = $file->get_imageinfo(); if( $image === false){ die("Aknown filehash $filehash"); return false; } $img_handle = imagecreatefromstring($file->get_content()); $mime = $image[ 'mimetype']; $img_numbers = imageCreateFromPNG( $filenamenumbers); $size_numbers = getimagesize ($filenamenumbers); Header ("Content-type: $mime"); $color = ImageColorAllocate ($img_handle, 100, 100, 100); $width = $image[ 'width']; $height = $image[ 'height']; $pos = 0; $font = 1; for($y = 0; $y < $rows; $y++){ for( $x=0; $x < $cols; $x++){ $pos++; if( !array_key_exists( $pos, $found)){ $x1 = $x * $width / $cols; $y1 = $y * $height / $rows; imagefilledrectangle( $img_handle, $x1, $y1, $x1 + $width / $cols, $y1 + $height / $rows, $color); if( array_key_exists( $pos, $cells)){ shownumber( $img_handle, $img_numbers, $pos, $x1 , $y1, $width / $cols, $height / $rows, $size_numbers); } } } } switch( $mime){ case 'image/png': ImagePng ($img_handle); break; case 'image/jpeg': ImageJpeg ($img_handle); break; case 'image/gif': ImageGif ($img_handle); break; default: die('Aknown mime type $mime'); return false; } ImageDestroy ($img_handle); } function shownumber( $img_handle, $img_numbers, $number, $x1 , $y1, $width, $height, $size_numbers){ if( $number < 10){ $width_number = $size_numbers[ 0] / 10; $dstX = $x1 + $width / 3; $dstY = $y1 + $height / 3; $srcX = $number * $size_numbers[ 0] / 10; $srcW = $size_numbers[ 0]/10; $srcH = $size_numbers[ 1]; $dstW = $width / 10; $dstH = $dstW * $srcH / $srcW; imagecopyresized( $img_handle, $img_numbers, $dstX, $dstY, $srcX, 0, $dstW, $dstH, $srcW, $srcH); }else { $number1 = floor( $number / 10); $number2 = $number % 10; shownumber( $img_handle, $img_numbers, $number1, $x1-$width/20, $y1, $width, $height, $size_numbers); shownumber( $img_handle, $img_numbers, $number2, $x1+$width/20, $y1, $width, $height, $size_numbers); } }