Saves the edited image as a file based on the original images file type
12605
public function toFile()
    {


        if ($this->type == "jpg")

    {
            $this->toJpg();

        } elseif ($this->type == "png") {

            $this->toPng();

        } elseif ($this->type == "gif") {

            $this->toGif();
        }

    }
490837
def redo(self, *args):
        """"""
        if not self.gui_up:
            return

        mod_only = self.w.modified_only.get_state()
        treedict = Bunch.caselessDict()
        self.treeview.clear()
        self.w.status.set_text('')

        channel = self.fv.get_channel(self.chname)
        if channel is None:
            return

        # Only list modified images for saving. Scanning Datasrc is enough.
        if mod_only:
            all_keys = channel.datasrc.keys(sort='alpha')

        # List all images in the channel.
        else:
            all_keys = channel.get_image_names()

        # Extract info for listing and saving
        for key in all_keys:
            iminfo = channel.get_image_info(key)
            path = iminfo.get('path')
            idx = iminfo.get('idx')
            t = iminfo.get('time_modified')

            if path is None:  # Special handling for generated buffer, eg mosaic
                infile = key
                is_fits = True
            else:
                infile = os.path.basename(path)
                infile_ext = os.path.splitext(path)[1]
                infile_ext = infile_ext.lower()
                is_fits = False

                if 'fit' in infile_ext:
                    is_fits = True

            # Only list FITS files unless it is Ginga generated buffer
            if not is_fits:
                continue

            # Only list modified buffers
            if mod_only and t is None:
                continue

            # More than one ext modified, append to existing entry
            if infile in treedict:
                if t is not None:
                    treedict[infile].extlist.add(idx)
                    elist = sorted(treedict[infile].extlist)
                    treedict[infile].MODEXT = ';'.join(
                        map(self._format_extname, elist))

            # Add new entry
            else:
                if t is None:
                    s = ''
                    extlist = set()
                else:
                    s = self._format_extname(idx)
                    extlist = set([idx])
                treedict[infile] = Bunch.Bunch(
                    IMAGE=infile, MODEXT=s, extlist=extlist, path=path)

        self.treeview.set_tree(treedict)

        # Resize column widths
        n_rows = len(treedict)
        if n_rows == 0:
            self.w.status.set_text('Nothing available for saving')
        elif n_rows < self.settings.get('max_rows_for_col_resize', 5000):
            self.treeview.set_optimal_column_widths()
            self.logger.debug('Resized columns for {0} row(s)'.format(n_rows))
671544
def save_image(image, destination=None, filename=None, **options):
    
    if destination is None:
        destination = BytesIO()
    filename = filename or ''
    # Ensure plugins are fully loaded so that Image.EXTENSION is populated.
    Image.init()
    format = Image.EXTENSION.get(os.path.splitext(filename)[1].lower(), 'JPEG')
    if format in ('JPEG', 'WEBP'):
        options.setdefault('quality', 85)
    saved = False
    if format == 'JPEG':
        if image.mode.endswith('A'):
            # From PIL 4.2, saving an image with a transparency layer raises an
            # IOError, so explicitly remove it.
            image = image.convert(image.mode[:-1])
        if settings.THUMBNAIL_PROGRESSIVE and (
                max(image.size) >= settings.THUMBNAIL_PROGRESSIVE):
            options['progressive'] = True
        try:
            image.save(destination, format=format, optimize=1, **options)
            saved = True
        except IOError:
            # Try again, without optimization (PIL can't optimize an image
            # larger than ImageFile.MAXBLOCK, which is 64k by default). This
            # shouldn't be triggered very often these days, as recent versions
            # of pillow avoid the MAXBLOCK limitation.
            pass
    if not saved:
        image.save(destination, format=format, **options)
    if hasattr(destination, 'seek'):
        destination.seek(0)
    return destination
43710
def serialize(self, image):
        
        pic = mutagen.flac.Picture()
        pic.data = image.data
        pic.type = image.type_index
        pic.mime = image.mime_type
        pic.desc = image.desc or u''
        return pic
1195547
def save(opts = {})
      save_png(opts) if Array(opts[:format]).include? :png
      save_pdf(opts) if Array(opts[:format]).include? :pdf
      self
    end
1220466
def save(self, name, content, *args, **kwargs):
        
        options = getattr(self.field, 'resize_source', None)
        if options:
            if 'quality' not in options:
                options['quality'] = self.thumbnail_quality
            content = Thumbnailer(content, name).generate_thumbnail(options)
            # If the generated extension differs from the original, use it
            # instead.
            orig_name, ext = os.path.splitext(name)
            generated_ext = os.path.splitext(content.name)[1]
            if generated_ext.lower() != ext.lower():
                name = orig_name + generated_ext
        super(ThumbnailerImageFieldFile, self).save(name, content, *args,
                                                    **kwargs)
26733
def _original_images(self, **kwargs):
        

        def test(image):
            if not image.original:
                return False
            for filter, value in kwargs.items():
                if getattr(image, filter) != value:
                    return False
            return True

        if Session.object_session(self.instance) is None:
            images = []
            for image, store in self._stored_images:
                if test(image):
                    images.append(image)

            state = instance_state(self.instance)
            try:
                added = state.committed_state[self.attr.key].added_items
            except KeyError:
                pass
            else:
                for image in added:
                    if test(image):
                        images.append(image)
            if self.session:
                for image in self.session.new:
                    if test(image):
                        images.append(image)
        else:
            query = self.filter_by(original=True, **kwargs)
            images = query.all()
        return images
421589
def save_intermediate_img(self, img, name):
        """"""
        if self.intermediate_results:
            img.writeto(name, overwrite=True)
107815
def save_plain_image_as_file(self, filepath, format='png', quality=90):
        
        pixbuf = self.get_plain_image_as_pixbuf()
        options = {}
        if format == 'jpeg':
            options['quality'] = str(quality)
        pixbuf.save(filepath, format, options)
74917
def __generic_save(self):
        """"""
        page = self._get_page()
        f = page.editor.f
        if not f:
            return True
        if not page.editor.flag_valid:
            a99.show_error("Cannot save, {0!s} has error(s)!".format(f.description))
            return True
        if f.filename:
            f.save_as()

            self.add_log("Saved '{}'".format(f.filename))
            page.flag_changed = False
            self._update_gui_text_tabs()

            if hasattr(page.editor, "update_gui_label_fn"):
                page.editor.update_gui_label_fn()  # duck typing
            return True
        else:
            return self.__generic_save_as()
437240
def rerender(self):
        '''
        
        '''
        with self.fs.open(self.original, 'rb') as f_img:
            img = io.BytesIO(f_img.read())  # Store the image in memory to avoid overwritting
        self.save(img, filename=self.filename, bbox=self.bbox, overwrite=True)
535144
def save(path, im):
    
    from PIL import Image
    if im.dtype == np.uint8:
        pil_im = Image.fromarray(im)
    else:
        pil_im = Image.fromarray((im*255).astype(np.uint8))
    pil_im.save(path)
1011368
def save_with_exif_info(img, *args, **kwargs):
    
    if 'exif' in kwargs:
        exif = kwargs.pop('exif')
    else:
        exif = img.info.get('exif')
    img.save(*args, exif=exif, **kwargs)
1157405
def save(self):
        
        from settings import PROCESSORS
        from .filesystem import makedirs

        if self.im is None:
            # If we got here something very strange is going on that I can't even
            # predict.
            return  # pragma: no cover
        makedirs(self.output_path)
        for action, arg in self.actions:
            action = PROCESSORS[action]
            if self.frames:
                new_frames = []
                for frame in self.frames:
                    new_frames.append(action.process(frame, arg))
                self.frames = new_frames
            else:
                self.im = action.process(self.im, arg)

        self.im = optimize.optimize(self.im, fmt=self.format, quality=self.quality)

        kwargs = {
            'format': self.format,
            'optimize': True,
            'quality': self.quality,
        }
        if self.format == 'jpeg':
            kwargs['progressive'] = True

        if self.filename.startswith('s3://'):
            import cStringIO
            from filesystem import s3
            output = cStringIO.StringIO()
            if self.frames:
                images2gif.write_gif(output, self.frames)
            else:
                self.im.save(output, **kwargs)
            output.reset()
            s3.put_file(output, self.filename)
        else:
            if self.frames:
                images2gif.write_gif(self.filename, self.frames)
            else:
                self.im.save(self.filename, **kwargs)
389091
def save(self, vs, filetype):
        ''

        # use NTF to generate filename and delete file on context exit
        with tempfile.NamedTemporaryFile(suffix='.'+filetype) as temp:
            saveSheets(temp.name, vs)
            sync(1)
            p = subprocess.Popen(
                self.command,
                stdin=open(temp.name, 'r', encoding=options.encoding),
                stdout=subprocess.DEVNULL,
                close_fds=True)
            p.communicate()
228970
def import_image(image_path, object_class_name, finder_method, image_class_name, verbose=true)

	  	filename = File.basename(image_path, File.extname(image_path))

	  	imageable_object = object_class_name.constantize.where("#{finder_method} = ?", filename).first
	  	image_object = image_class_name.constantize.new
	  	image_object.imageable = imageable_object
	  	image_object.image = File.open(image_path)

	  	if image_object.valid?
	  		image_object.save
	  	else
	  		puts ""
	  		puts "Error while saving #{filename} - #{image_path}".red
	  		puts ""
	  	end
	  end
782868
def save_img(self, file_name=None, file_type="gif", mode='dot'):
        '''
        
        '''

        if not file_name:
            warnings.warn(DeprecationWarning, "always pass a file_name")
            file_name = "out"

        if  mode == 'neato':
            self.save_dot(self.temp_neo)
            neato_cmd = "%s -o %s %s" % (self.neato, self.temp_dot, self.temp_neo)
            os.system(neato_cmd)
            plot_cmd = self.dot
        else:
            self.save_dot(self.temp_dot)
            plot_cmd = self.dot

        file_name  = "%s.%s" % (file_name, file_type)
        create_cmd = "%s -T%s %s -o %s" % (plot_cmd, file_type, self.temp_dot, file_name)
        os.system(create_cmd)