Creates a png if needed.
167937
def png(contents, latex_command):
    """"""
    outfile = sha(contents + latex_command)
    src = os.path.join(IMAGEDIR, outfile + '.png')
    if not os.path.isfile(src):
        try:
            os.mkdir(IMAGEDIR)
            stderr.write('Created directory ' + IMAGEDIR + '\n')
        except OSError:
            pass
        latex2png(latex_command + "{" + contents + "}", outfile)
        stderr.write('Created image ' + src + '\n')
    return src
83130
protected function createImagineInstance()
    {
        $driver = ConfigQuery::read("imagine_graphic_driver", "gd");

        switch ($driver) {
            case 'imagick':
                $image = new ImagickImagine();
                break;

            case 'gmagick':
                $image = new GmagickImagine();
                break;

            case 'gd':
            default:
                $image = new Imagine();
        }

        return $image;
    }
1286445
def graph_png(self):
        
        if not self.out_file:
            ui.error(c.MESSAGES["png_missing_out"])
            sys.exit(1)

        cli_flags = "-Gsize='{0}' -Gdpi='{1}' {2} ".format(self.size, self.dpi,
                                                           self.flags)
        cli_flags += "-o {0}".format(self.out_file)

        (out, err) = utils.capture_shell(
            "ansigenome export -t graph -f dot | dot -Tpng {0}"
            .format(cli_flags))

        if err:
            ui.error(err)
989533
def to_png
      data = ""
      to_png_stream Proc.new { |chunk| data += chunk }
      yield data if block_given?
      data
    end
103507
function inlinePng(rootFolder, currentFile, $) {
    var currentDirectory = path.dirname(currentFile);

    return editHTMLElement($, 'img', function($img) {
        var src = $img.attr('src');
        if (!LocationUtils.isDataURI(src)) {
            return;
        }

        // We avoid generating twice the same PNG
        var hash = crc.crc32(src).toString(16);
        var fileName = hash + '.png';

        // Result file path
        var filePath = path.join(rootFolder, fileName);

        return fs.assertFile(filePath, function() {
            return imagesUtil.convertInlinePNG(src, filePath);
        })
        .then(function() {
            // Convert filename to a relative filename
            fileName = LocationUtils.relative(currentDirectory, fileName);

            // Replace src
            $img.attr('src', fileName);
        });
    });
}
555398
def encode_images_as_png(images):
  """"""
  if tf.executing_eagerly():
    for image in images:
      yield tf.image.encode_png(image).numpy()
  else:
    (height, width, channels) = images[0].shape
    with tf.Graph().as_default():
      image_t = tf.placeholder(dtype=tf.uint8, shape=(height, width, channels))
      encoded_image_t = tf.image.encode_png(image_t)
      with tf.Session() as sess:
        for image in images:
          enc_string = sess.run(encoded_image_t, feed_dict={image_t: image})
          yield enc_string
1195547
def save(opts = {})
      save_png(opts) if Array(opts[:format]).include? :png
      save_pdf(opts) if Array(opts[:format]).include? :pdf
      self
    end
1046355
public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE)
    {
        $image = self::image($frame, $pixelPerPoint, $outerFrame);

        if ($filename === false) {
            Header("Content-type: image/png");
            ImagePng($image);
        } else {
            if($saveandprint===TRUE){
                ImagePng($image, $filename);
                header("Content-type: image/png");
                ImagePng($image);
            }else{
                ImagePng($image, $filename);
            }
        }

        ImageDestroy($image);
    }
1230649
def _repr_png_(self):
        
        app.process_events()
        QApplication.processEvents()

        img = read_pixels()
        return bytes(_make_png(img))
342810
def _repr_png_(self):
        """"""
        b = BytesIO()
        im = self.as_pil_image()
        im.save(b, 'PNG')
        return b.getvalue()
769244
public static byte[] generatePng(String content, int width, int height) {
		final ByteArrayOutputStream out = new ByteArrayOutputStream();
		generate(content, width, height, ImgUtil.IMAGE_TYPE_PNG, out);
		return out.toByteArray();
	}
561368
@GetMapping(path = {"/otp/qrgen"})
    public void generate(final HttpServletResponse response, final HttpServletRequest request) throws Exception {
        response.setContentType("image/png");
        val key = request.getParameter("key");
        QRUtils.generateQRCode(response.getOutputStream(), key, QRUtils.WIDTH_LARGE, QRUtils.WIDTH_LARGE);
    }
1181528
def png(file, box, paint, trans)
      Squib.logger.debug {"RENDERING PNG: \n  file: #{file}\n  box: #{box}\n  paint: #{paint}\n  trans: #{trans}"}
      return if file.nil? or file.eql? ''
      png = Squib.cache_load_image(file)
      use_cairo do |cc|
        cc.translate(box.x, box.y)
        box.width    = png.width.to_f  if box.width  == :native
        box.height   = png.height.to_f if box.height == :native
        box.width    = png.width.to_f * box.height.to_f / png.height.to_f if box.width == :scale
        box.height   = png.height.to_f * box.width.to_f / png.width.to_f  if box.height == :scale

        scale_width  = box.width.to_f / png.width.to_f
        scale_height = box.height.to_f / png.height.to_f
        warn_png_scale(file, scale_width, scale_height)
        cc.scale(scale_width, scale_height)

        cc.rotate(trans.angle)
        cc.flip(trans.flip_vertical, trans.flip_horizontal, box.width / 2, box.height / 2)
        cc.translate(-box.x, -box.y)

        trans.crop_width  = png.width.to_f  if trans.crop_width  == :native
        trans.crop_height = png.height.to_f if trans.crop_height == :native
        cc.rounded_rectangle(box.x, box.y, trans.crop_width, trans.crop_height, trans.crop_corner_x_radius, trans.crop_corner_y_radius)
        cc.clip
        cc.translate(-trans.crop_x, -trans.crop_y)


        cc.set_source(png, box.x, box.y)
        cc.operator = paint.blend unless paint.blend == :none
        if paint.mask.empty?
          cc.paint(paint.alpha)
        else
          cc.set_source_squibcolor(paint.mask)
          cc.mask(png, box.x, box.y)
        end
      end
    end
491399
def _make_sprite_image(images, save_path):
    """"""
    if isinstance(images, np.ndarray):
        images = nd.array(images, dtype=images.dtype, ctx=current_context())
    elif not isinstance(images, (NDArray, np.ndarray)):
        raise TypeError('images must be an MXNet NDArray or numpy.ndarray,'
                        ' while received type {}'.format(str(type(images))))

    assert isinstance(images, NDArray)
    shape = images.shape
    nrow = int(np.ceil(np.sqrt(shape[0])))
    _save_image(
        images, os.path.join(save_path, 'sprite.png'), nrow=nrow, padding=0, square_image=True)
1291360
def create_rbd_image(service, pool, image, sizemb):
    """"""
    cmd = ['rbd', 'create', image, '--size', str(sizemb), '--id', service,
           '--pool', pool]
    check_call(cmd)
455869
def gen_image(img, width, height, outfile, img_type='grey'):
    """"""
    assert len(img) == width * height or len(img) == width * height * 3

    if img_type == 'grey':
        misc.imsave(outfile, img.reshape(width, height))

    elif img_type == 'color':
        misc.imsave(outfile, img.reshape(3, width, height))
1100089
def save_as_png(self, filename, width=300, height=250, render_time=1):
        """"""
        self.driver.set_window_size(width, height)
        self.driver.get('file://{path}/{filename}'.format(
            path=os.getcwd(), filename=filename + ".html"))
        time.sleep(render_time)
        self.driver.save_screenshot(filename + ".png")