/*!
Stores the current image object to disk, the image is stored in the path \a $filePath with filename \a $fileName.
The parameter \a $type determines the image format, supported are \c png and \c jpg.
\return true if the image was stored correctly.
501649
function store( $fileName, $filePath, $type )
    {
        if ( !$this->IsProcessed )
            $this->process();
        $imageObject = $this->imageObject();
        switch( $type )
        {
            case 'png':
            {
                if ( !file_exists( $filePath ) )
                {
                    eZDir::mkdir( $filePath, false, true );
                }
                $fileFullPath = eZDir::path( array( $filePath, $fileName ) );
                ImagePNG( $imageObject, $fileFullPath );
                $this->StoredPath = $filePath;
                $this->StoredFile = $fileName;
                $this->StoredType = $type;
                return true;
            } break;

            case 'jpg':
            {
                if ( !file_exists( $filePath ) )
                {
                    eZDir::mkdir( $filePath, false, true );
                }
                ImageJPEG( $imageObject, eZDir::path( array( $filePath, $fileName ) ) );
                $this->StoredPath = $filePath;
                $this->StoredFile = $fileName;
                $this->StoredType = $type;
                return true;
            } break;

            default:
            {
                eZDebug::writeError( 'Image format not supported: ' . $type, __METHOD__ );
            }
        }
        return false;
    }
1158299
function processImage()
    {
        if ( $this->StoredFile == '' )
            return true;
        $fileArray = array( $this->StoredPath, $this->StoredFile );
        $filePath = eZDir::path( $fileArray );
        $imageinfo = getimagesize( $filePath );
        if ( $imageinfo )
        {
            $width = $imageinfo[0];
            $height = $imageinfo[1];
            if ( $this->load() )
            {
                $this->Width = $width;
                $this->Height = $height;
                return true;
            }
            else
                eZDebug::writeWarning( "Image failed to load '$filePath'", __METHOD__ );
        }
        else
            eZDebug::writeWarning( "No image info could be extracted from '$filePath'", __METHOD__ );
        return false;
    }
632390
public function store($storagePath = '', $filename = '')
    {
        $path     = $this->getPath();
        $pathinfo = pathinfo($path);
        $data     = file_get_contents($path);

        // Use Original Filename if no specific filename is set
        if (empty($filename)) {
            $filename = $pathinfo['filename'] . '.jpg';
        }

        file_put_contents($storagePath . $filename, $data);

        $this->setLocalStoragePath($storagePath);
        $this->setLocalFilename($filename);

        return $storagePath . $filename;
    }
1089868
def save_plain_image_as_file(self, filepath, format='png', quality=90):
        
        pixbuf = self.get_plain_image_as_pixbuf()
        options, values = [], []
        if format == 'jpeg':
            options.append('quality')
            values.append(str(quality))
        pixbuf.savev(filepath, format, options, values)
55350
public function getThumbnail($originalImagePath, $type)
    {
        if (array_key_exists($type, $this->getTypes())) {
            return preg_replace('#^(.*)\.(' . implode('|', $this->getAllowedExtensions()) . ')$#', '$1-' . $this->getThumbnailPrefix() . '-' . $type . '.$2', $originalImagePath);
        }

        return false;
    }
1330101
public function is_valid_image() {
        $mimetype = $this->get_mimetype();
        if (!file_mimetype_in_typegroup($mimetype, 'web_image')) {
            return false;
        }
        if (!$info = $this->get_imageinfo()) {
            return false;
        }
        if ($info['mimetype'] !== $mimetype) {
            return false;
        }
        // ok, GD likes this image
        return true;
    }
1350910
public function save($path)
    {

        switch ( $this->imageType ) {
            case IMAGETYPE_GIF:
                $returnData = imagegif( $this->image, $path );
                break;

            case IMAGETYPE_PNG:
                $returnData = imagepng( $this->image, $path );
                break;

            case IMAGETYPE_JPEG:
                $returnData = imagejpeg( $this->image, $path );
                break;

            case IMAGETYPE_BMP:
                $returnData = imagewbmp( $this->image, $path );
                break;

            // If the image is not one of the previous mimetype
            // We throw an exception
            default:
                throw new Exception( sprintf( 'This MimeType is not supported: %s. Image processed: %s', image_type_to_mime_type( $this->imageType ), $this->originalImagePath ) );
                break;
        }

        // Return this for chaning
        return $this;
    }
764838
def UploadType(cls, file_path):
        
        if not os.path.isabs(file_path):
            return False
        
        if os.path.isfile(file_path):
            cls.SendKeys(file_path)
        else:            
            return False
909130
public function save($filename, $image_type = null, $quality = null)
	{
		$quality = (int) $quality;
		if (empty($quality)) {
			$quality = 100;
		}
		
		if (null === $image_type) {
			$image_type = $this->image_type;
		}
		
		switch ($image_type) {
			case 'gif':
			case IMAGETYPE_GIF:
				$success = imagegif($this->image, $filename);
				break;
				
			case 'png':
			case IMAGETYPE_PNG:
				$quality = 9 - round(($quality / 100) * 9);
				$success = imagepng($this->image, $filename, $quality);
				break;
				
			case 'jpeg':
			case 'jpg':
			case IMAGETYPE_JPEG:
			default:
				$success = imagejpeg($this->image, $filename, $quality);
				break;
		}
		
		return $success;
	}
480849
public function is_image($path){
        if( !file_exists($path) || !($info = getimagesize($path)) ){
            return false;
        }
        return (bool) preg_match("/^image\/(jpeg|png|gif)$/", $info['mime']);
    }
111363
public function isImage()
	{
		$mime = $this->getMimeType();
		
		// The $imageMimes property contains an array of file extensions and
		// their associated MIME types. We will loop through them and look for 
		// the MIME type of the current SymfonyUploadedFile.
		foreach ($this->imageMimes as $imageMime)
		{
			if (in_array($mime, (array) $imageMime))
			{
				return true;
			}
		}

		return false;
	}
188946
public function save($savePath, $imageQuality = 95)
        {
            // If the image wasn't resized, fetch original image.
            if (!$this->imageResized) {
                $this->imageResized = $this->image;
            }

            // Get extension of the output file.
            $extension = Inflector::lower(File::extension($savePath));

            // Create and save an image based on it's extension.
            switch($extension)
            {
                case 'jpg':
                case 'jpeg':
                    if (imagetypes() & IMG_JPG) {
                        imagejpeg($this->imageResized, $savePath, $imageQuality);
                    }
                    break;

                case 'gif':
                    if (imagetypes() & IMG_GIF) {
                        imagegif($this->imageResized, $savePath);
                    }
                    break;

                case 'png':
                    // Scale quality from 0-100 to 0-9.
                    $scaleQuality = round(($imageQuality / 100) * 9);

                    // Invert quality setting as 0 is best, not 9.
                    $invertScaleQuality = 9 - $scaleQuality;

                    if (imagetypes() & IMG_PNG) {
                        imagepng($this->imageResized, $savePath, $invertScaleQuality);
                    }
                    break;

                default:
                    return false;
                    break;
            }

            // Remove the resource for the resized image.
            imagedestroy($this->imageResized);

            return true;
        }
808362
function get_file($srcpath, $localpath) {

        $localpath = $this->utf_decode_path($localpath);

        $handle = fopen($localpath, 'wb');
        if ($handle) {
            $unused = '';
            $ret = $this->get($srcpath, $unused, $handle);
            fclose($handle);
            if ($ret) {
                return true;
            }
        }
        return false;
    }
250026
public function uploadImage($filePath)
    {
        $result = $this->wechat->httpPost(self::WECHAT_IMG_UPLOAD_PREFIX, [
            'buffer' => class_exists('\CURLFile') ? new \CURLFile($filePath) : '@' . $filePath
        ], [
            'access_token' => $this->wechat->getAccessToken()
        ]);

        return isset($result['url']) ? $result['url'] : false;
    }
169033
public function save(string $path, string $name, ?string $extension = null, int $quality = 100): bool
    {
        if (false === is_dir($path)) {
            mkdir($path, 0777, true);
        }
        if (null === $extension) {
            /** @var string $extension */
            $extension = $this->extension;
        }
        if (true === $this->encrypted) {
            file_put_contents($path . $name . '.' . self::FORMAT_WD_IMAGE, $this->workingData);
            return true;
        } elseif (0 !== imagetypes()) {
            $filename = $path . $name . '.' . $extension;
            switch (strtolower($extension)) {
                case self::FORMAT_GIF:
                    imagegif($this->workingData, $filename);
                    break;
                case self::FORMAT_JPEG:
                case self::FORMAT_JPG:
                    imagejpeg($this->workingData, $filename, $quality);
                    break;
                case self::FORMAT_PNG:
                    imagepng($this->workingData, $filename, (int)round(9 - ((9 * $quality) / 100)));
                    break;
                default:
                    throw new ImageException('Unsupported file type');
            }
            return false;
        }
    }
793223
function filetype($path)
    {
        $type = $this->_get_stat_cache_prop($path, 'type');
        if ($type === false) {
            return false;
        }

        switch ($type) {
            case NET_SFTP_TYPE_BLOCK_DEVICE:
                return 'block';
            case NET_SFTP_TYPE_CHAR_DEVICE:
                return 'char';
            case NET_SFTP_TYPE_DIRECTORY:
                return 'dir';
            case NET_SFTP_TYPE_FIFO:
                return 'fifo';
            case NET_SFTP_TYPE_REGULAR:
                return 'file';
            case NET_SFTP_TYPE_SYMLINK:
                return 'link';
            default:
                return false;
        }
    }
287394
protected function storeImage($imagePath)
    {
        /**
         * @var \Elcodi\Component\Media\Services\ImageManager                 $imageManager
         * @var \Gaufrette\Filesystem                                         $filesystem
         * @var \Elcodi\Component\Media\Transformer\FileIdentifierTransformer $fileIdentifierTransformer
         * @var \Doctrine\Common\Persistence\ObjectManager                    $imageObjectManager
         */
        $imageManager = $this->get('elcodi.manager.media_image');
        $imageObjectManager = $this->get('elcodi.object_manager.image');
        $filesystem = $this->get('elcodi.media_filesystem');
        $fileIdentifierTransformer = $this->get('elcodi.transformer.media_file_identifier');

        $image = $imageManager->createImage(new \Symfony\Component\HttpFoundation\File\File($imagePath));
        $imageObjectManager->persist($image);
        $imageObjectManager->flush($image);

        $filesystem->write(
            $fileIdentifierTransformer->transform($image),
            file_get_contents($imagePath),
            true
        );

        return $image;
    }