Import preview image
517238
protected function importPreviewImage()
    {
        if (!$this->bNeedUpdatePreviewImage) {
            return;
        }

        $obPreviewImage = $this->obModel->preview_image;
        if (empty($obPreviewImage) && empty($this->sPreviewImage)) {
            return;
        }

        if (empty($obPreviewImage) && !empty($this->sPreviewImage)) {
            //Create new preview
            $obPreviewImage = new File();
            $obPreviewImage->fromFile($this->sPreviewImage);
            $this->obModel->preview_image()->add($obPreviewImage);

            return;
        }

        if (!file_exists($obPreviewImage->getLocalPath())) {
            $obPreviewImage->fromFile($this->sPreviewImage);
            $obPreviewImage->save();
        } elseif (!empty($this->sPreviewImage) && file_exists($obPreviewImage->getLocalPath()) && md5_file($this->sPreviewImage) != md5_file($obPreviewImage->getLocalPath())) {
            //Update preview image
            $obPreviewImage->deleteThumbs();
            $obPreviewImage->fromFile($this->sPreviewImage);
            $obPreviewImage->save();
        } elseif (!empty($obPreviewImage) && empty($this->sPreviewImage)) {
            $obPreviewImage->deleteThumbs();
            $obPreviewImage->delete();
        }
    }
454983
def import_imageinfo(path, base = nil, allow_exts = nil)
      return nil unless File.exist?(path)
      allow_exts ||= @config['image_ext']
      Dir.foreach(path) do |f|
        next if f.start_with?('.')
        if f =~ /\.(#{allow_exts.join('|')})\Z/i
          path.chop! if path =~ %r{/\Z}
          if base.nil?
            @contents.push(EPUBMaker::Content.new('file' => "#{path}/#{f}"))
          else
            @contents.push(EPUBMaker::Content.new('file' => "#{path.sub(base + '/', '')}/#{f}"))
          end
        end
        if FileTest.directory?("#{path}/#{f}")
          import_imageinfo("#{path}/#{f}", base)
        end
      end
    end
550169
def import_image(self, name, tags=None):
        
        stream_import_file = os.path.join(self.os_conf.get_build_json_store(),
                                          'image_stream_import.json')
        with open(stream_import_file) as f:
            stream_import = json.load(f)
        return self.os.import_image(name, stream_import, tags=tags)
643186
def write_preview_to_file(path)
      FileUtils.mkdir_p(File.dirname(path))
      File.open(path, 'wb') do |out|
        out.write(preview_data)
      end
    end
1127425
def resize_preview(self, dw, dh):
        ""

        # identify preview
        if self._objects_moving:
            id_ = self._objects_moving[0]
            tags = self.canvas.gettags(id_)
            for tag in tags:
                if tag.startswith('preview_'):
                    _, ident = tag.split('preview_')
                    preview = self.previews[ident]
                    preview.resize_by(dw, dh)
                    self.move_previews()
                    break
        self._update_cregion()
204890
async function importCustomSelectorsFromCSSFile(from) {
	const css = await readFile(path.resolve(from));
	const root = postcss.parse(css, { from: path.resolve(from) });

	return importCustomSelectorsFromCSSAST(root);
}
891990
def show(self):
        """"""

        # noinspection PyPackageRequirements
        from IPython.display import Image, display

        fname = self.render()
        display(Image(filename=fname))
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
368941
public void updateImage(FlowPanel container, Image previewImage) {

        if (!ENABLED) {
            return;
        }
        String path = m_imageInfoProvider.get().getResourcePath();
        if (CmsClientStringUtil.checkIsPathOrLinkToSvg(path)) {
            return;
        }
        m_image = previewImage;
        clearImagePoint();
        m_savedFocalPoint = m_imageInfoProvider.get().getFocalPoint();
        m_focalPoint = m_savedFocalPoint;
        m_container = container;

        previewImage.addLoadHandler(new LoadHandler() {

            @SuppressWarnings("synthetic-access")
            public void onLoad(LoadEvent event) {

                updateScaling();
                updatePoint();
            }

        });
    }
570645
def load_img(name):
    """"""

    fullname = name
    try:
        image = pygame.image.load(fullname)
        if image.get_alpha() is None:
            image = image.convert()
        else:
            image = image.convert_alpha()
    except pygame.error, message:
        print "Error: couldn't load image: ", fullname
        raise SystemExit, message
    return (image, image.get_rect())
844302
def download(client, target_dir):
    """"""
    print('download image previews')
    print(
        "Warning! Downloaded images are only previews!"
        "They may be to small for upload.")
    tree = {}
    listings = client.list('listings')
    languages = map(lambda listing: listing['language'], listings)

    parameters = [{'imageType': image_type, 'language': language}
                  for image_type in image_types for language in languages]
    tree = {image_type: {language: list()
                         for language in languages}
            for image_type in image_types}

    for params in parameters:
        result = client.list('images', **params)
        image_type = params['imageType']
        language = params['language']
        tree[image_type][language] = map(
            lambda r: r['url'], result)

    for image_type, language_map in tree.items():
        for language, files in language_map.items():
            if len(files) > 0:
                mkdir_p(
                    os.path.join(target_dir, 'images', image_type, language))
            if image_type in single_image_types:
                if len(files) > 0:
                    image_url = files[0]
                    path = os.path.join(
                        target_dir,
                        'images',
                        image_type,
                        language,
                        image_type)
                    load_and_save_image(image_url, path)
            else:
                for idx, image_url in enumerate(files):
                    path = os.path.join(
                        target_dir,
                        'images',
                        image_type,
                        language,
                        image_type + '_' + str(idx))
                    load_and_save_image(image_url, path)
1005062
def open_image(fn:PathOrStr, div:bool=True, convert_mode:str='RGB', cls:type=Image,
        after_open:Callable=None)->Image:
    ""
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", UserWarning) # EXIF warning from TiffPlugin
        x = PIL.Image.open(fn).convert(convert_mode)
    if after_open: x = after_open(x)
    x = pil2tensor(x,np.float32)
    if div: x.div_(255)
    return cls(x)
308534
def dump(self):
        """"""
        scan_lines = bytearray()
        for y in range(self.height):
            scan_lines.append(0)  # filter type 0 (None)
            scan_lines.extend(
                self.canvas[(y * self.width * 4):((y + 1) * self.width * 4)]
            )
        # image represented as RGBA tuples, no interlacing
        return SIGNATURE + \
            self.pack_chunk(b'IHDR', struct.pack(b"!2I5B",
                                                 self.width, self.height,
                                                 8, 6, 0, 0, 0)) + \
            self.pack_chunk(b'IDAT', zlib.compress(bytes(scan_lines), 9)) + \
            self.pack_chunk(b'IEND', b'')
365580
public function preview()
	{
		$sizes = \System::getContainer()->get('contao.image.image_sizes')->getAllOptions();
		$size = StringUtil::deserialize($this->size);
		
		if (is_numeric($size[2]))
		{
			return '<div class="widget"><span style="color:#b3b3b3 ">' . $sizes['image_sizes'][$size[2]] . '</span></div>';
		}
		else
		{
			return '<div class="widget"><span style="color:#b3b3b3 ">' . $GLOBALS['TL_LANG']['MSC'][$size[2]][0] . ' (' . $size[0] . 'x' . $size[1] . ')</span></div>';
		}
	}
1057705
def _import_images(controller, path):
    
    image_dir = controller.images_path()

    root = os.path.join(path, "images")
    for (dirpath, dirnames, filenames) in os.walk(root):
        for filename in filenames:
            path = os.path.join(dirpath, filename)
            dst = os.path.join(image_dir, os.path.relpath(path, root))
            os.makedirs(os.path.dirname(dst), exist_ok=True)
            shutil.move(path, dst)
1083046
def get_document_preview(user_name, intra_hash, file_name, size)
      response = @conn.get get_document_href(user_name, intra_hash, file_name), { :preview => size }
      if response.status == 200
        return [response.body, 'image/jpeg']
      end
      return nil, nil
    end
1065205
def import_image(image_path, os_version):
    
    image_name = os.path.basename(image_path)
    print("\nChecking if image %s exists ..." % image_name)

    image_query_info = client.send_request('image_query', imagename = image_name)
    if image_query_info['overallRC']:
        print("Importing image %s ..." % image_name)
        url = "file://" + image_path
        image_import_info = client.send_request('image_import', image_name, url, 
                                                {'os_version': os_version})
        if image_import_info['overallRC']:
            raise RuntimeError("Failed to import image %s!\n%s" % 
                               (image_name, image_import_info))
        else:
            print("Succeeded to import image %s!" % image_name)
    else:
        print("Image %s already exists!" % image_name)