continuar
   Código PHP:
     
    /**
     *  Creates a target image identifier
     *
     *  @access private
     */
    function create_target_image_identifier($width, $height)
    {
    
        // creates a blank image
        $targetImageIdentifier = imagecreatetruecolor((int)$width <= 0 ? 1 : (int)$width, (int)$height <= 0 ? 1 : (int)$height);
        
        // if we have transparency in the image
        if (isset($this->transparentColorRed) && isset($this->transparentColorGreen) && isset($this->transparentColorBlue)) {
        
            $transparent = imagecolorallocate($targetImageIdentifier, $this->transparentColorRed, $this->transparentColorGreen, $this->transparentColorBlue);
 
            imagefilledrectangle($targetImageIdentifier, 0, 0, $width, $height, $transparent);
 
            imagecolortransparent($targetImageIdentifier, $transparent);
            
        }
        
        // return target image identifier
        return $targetImageIdentifier;
        
    }
 
    /**
     *  creates a new image from a given image identifier
     *
     *  @access private
     */
    function output_target_image($targetImageIdentifier)
    {
    
        // get target file extension
        $targetFileExtension = strtolower(substr($this->targetFile, strrpos($this->targetFile, ".") + 1));
        
        // image saving process goes according to required extension
        switch ($targetFileExtension) {
        
            // if gif
            case "gif":
            
                // if gd support for this file type is not available
                if (!function_exists("imagegif")) {
                
                    // save the error level and stop the execution of the script
                    $this->error = 6;
 
                    return false;
                    
                // if, for some reason, file could not be created
                } elseif (@!imagegif($targetImageIdentifier, $this->targetFile)) {
                
                    // save the error level and stop the execution of the script
                    $this->error = 3;
 
                    return false;
                    
                }
                
                break;
                
            // if jpg
            case "jpg":
            case "jpeg":
            
                // if gd support for this file type is not available
                if (!function_exists("imagejpeg")) {
                
                    // save the error level and stop the execution of the script
                    $this->error = 6;
 
                    return false;
                    
                // if, for some reason, file could not be created
                } elseif (@!imagejpeg($targetImageIdentifier, $this->targetFile, $this->jpegOutputQuality)) {
                
                    // save the error level and stop the execution of the script
                    $this->error = 3;
 
                    return false;
                    
                }
                
                break;
                
            case "png":
            
                // if gd support for this file type is not available
                if (!function_exists("imagepng")) {
                
                    // save the error level and stop the execution of the script
                    $this->error = 6;
 
                    return false;
                    
                // if, for some reason, file could not be created
                } elseif (@!imagepng($targetImageIdentifier, $this->targetFile)) {
                
                    // save the error level and stop the execution of the script
                    $this->error = 3;
 
                    return false;
                    
                }
                
                break;
                
            // if not a supported file extension
            default:
            
                // save the error level and stop the execution of the script
                $this->error = 5;
 
                return false;
                
        }
        
        // if file was created successfully
        // chmod the file
        chmod($this->targetFile, intval($this->chmodValue, 8));
        
        // if the date/time of the target file should be the same as the source file's
        if ($this->preserveSourceFileTime) {
        
            // touch the newly created file
            @touch($this->targetFile, $this->sourceFileTime);
            
        }
        
        // and return true
        return true;
        
    }