Reads the image from the requested URL, rotates it, and returns
it in the
Servlet stream. See above for details on parameters.
962290
protected RenderedImage doFilter(BufferedImage pImage, ServletRequest pRequest, ImageServletResponse pResponse) {
        // Get angle
        double ang = getAngle(pRequest);

        // Get bounds
        Rectangle2D rect = getBounds(pRequest, pImage, ang);
        int width = (int) rect.getWidth();
        int height = (int) rect.getHeight();

        // Create result image
        BufferedImage res = ImageUtil.createTransparent(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g = res.createGraphics();

        // Get background color and clear
        String str = pRequest.getParameter(PARAM_BGCOLOR);
        if (!StringUtil.isEmpty(str)) {
            Color bgcolor = StringUtil.toColor(str);
            g.setBackground(bgcolor);
            g.clearRect(0, 0, width, height);
        }

        // Set mHints (why do I always get jagged edgdes?)
        RenderingHints hints = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
        hints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
        hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC));

        g.setRenderingHints(hints);

        // Rotate around center
        AffineTransform at = AffineTransform
                .getRotateInstance(ang, width / 2.0, height / 2.0);

        // Move to center
        at.translate(width / 2.0 - pImage.getWidth() / 2.0,
                     height / 2.0 - pImage.getHeight() / 2.0);

        // Draw it, centered
        g.drawImage(pImage, at, null);

        return res;
    }
1281294
public BufferedImage getImage(String urlStr) throws FlickrException {
        InputStream in = null;
        try {
            URL url = new URL(urlStr);
            HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
            if (transport instanceof REST) {
                if (((REST) transport).isProxyAuth()) {
                    conn.setRequestProperty("Proxy-Authorization", "Basic " + ((REST) transport).getProxyCredentials());
                }
            }
            conn.connect();
            in = conn.getInputStream();
            return ImageIO.read(in);
        } catch (IOException e) {
            throw new FlickrException(e.getMessage(), e.getCause());
        } finally {
            IOUtilities.close(in);
        }
    }
934229
public InputStream createResourceAsStream(GeneratorContext context) {
		
		ServletContext servletContext = context.getConfig().getContext();
		return servletContext.getResourceAsStream("/img/"+context.getPath());
	}
192635
public JSONObject sendImageRequest(String url, String image, HashMap<String, Object> options) {
        try {
            byte[] data = Util.readFileByBytes(image);
            return sendImageRequest(url, data, options);
        } catch (IOException e) {
            e.printStackTrace();
            return AipError.IMAGE_READ_ERROR.toJsonResult();
        }
    }
94753
def get_image(cls, url):
        
        from PIL.ImageFile import Parser as PILParser

        length = 0
        raw_image = None
        with closing(request.get(url, stream=True)) as response:
            response.raise_for_status()
            response_url = response.url
            parser = PILParser()
            for chunk in response.iter_content(config.CHUNK_SIZE):
                length += len(chunk)
                if length > config.IMAGE_MAX_BYTESIZE:
                    del parser
                    raise cls.MaxBytesException
                parser.feed(chunk)
                # comment this to get the whole file
                if parser.image and parser.image.size:
                    raw_image = parser.image
                    del parser # free some memory
                    break
            # or this to get just the size and format
            # raw_image = parser.close()
        if length == 0:
            raise cls.ZeroBytesException
        if not raw_image:
            raise cls.NoImageException
        image = Image(response_url, raw_image.size, raw_image.format)
        return image
1080234
def loader():
    """"""
    url = request.args.get('url')  # read image URL as a request URL param
    response = requests.get(url)  # make request to static image file
    return response.content
364719
public static Image getInstance(byte imgb[]) throws BadElementException,
			MalformedURLException, IOException {
		InputStream is = null;
		try {
			is = new java.io.ByteArrayInputStream(imgb);
			int c1 = is.read();
			int c2 = is.read();
			int c3 = is.read();
			int c4 = is.read();
			is.close();

			is = null;
			if (c1 == 'G' && c2 == 'I' && c3 == 'F') {
				GifImage gif = new GifImage(imgb);
				return gif.getImage(1);
			}
			if (c1 == 0xFF && c2 == 0xD8) {
				return new Jpeg(imgb);
			}
			if (c1 == 0x00 && c2 == 0x00 && c3 == 0x00 && c4 == 0x0c) {
				return new Jpeg2000(imgb);
			}
			if (c1 == 0xff && c2 == 0x4f && c3 == 0xff && c4 == 0x51) {
				return new Jpeg2000(imgb);
			}
			if (c1 == PngImage.PNGID[0] && c2 == PngImage.PNGID[1]
					&& c3 == PngImage.PNGID[2] && c4 == PngImage.PNGID[3]) {
				return PngImage.getImage(imgb);
			}
			if (c1 == 0xD7 && c2 == 0xCD) {
				return new ImgWMF(imgb);
			}
			if (c1 == 'B' && c2 == 'M') {
				return BmpImage.getImage(imgb);
			}
			if ((c1 == 'M' && c2 == 'M' && c3 == 0 && c4 == 42)
					|| (c1 == 'I' && c2 == 'I' && c3 == 42 && c4 == 0)) {
				RandomAccessFileOrArray ra = null;
				try {
					ra = new RandomAccessFileOrArray(imgb);
					Image img = TiffImage.getTiffImage(ra, 1);
                    if (img.getOriginalData() == null)
                        img.setOriginalData(imgb);
					return img;
				} finally {
					if (ra != null)
						ra.close();
				}

			}
			if ( c1 == 0x97 && c2 == 'J' && c3 == 'B' && c4 == '2' ) {
				is = new java.io.ByteArrayInputStream(imgb);
				is.skip(4);
				int c5 = is.read();
				int c6 = is.read();
				int c7 = is.read();
				int c8 = is.read();
				if ( c5 == '\r' && c6 == '\n' && c7 == 0x1a && c8 == '\n' ) {
					int file_header_flags = is.read();
					@SuppressWarnings("unused")
					int number_of_pages = -1;
					if ( (file_header_flags & 0x2) == 0x2 ) {
						number_of_pages = (is.read() << 24) | (is.read() << 16) | (is.read() << 8) | is.read();
					}
					is.close();
					// a jbig2 file with a file header.  the header is the only way we know here.                                                           
					// embedded jbig2s don't have a header, have to create them by explicit use of Jbig2Image?
					// nkerr, 2008-12-05  see also the getInstance(URL)
					RandomAccessFileOrArray ra = null;
					try {
						ra = new RandomAccessFileOrArray(imgb);
						Image img = JBIG2Image.getJbig2Image(ra, 1);
						if (img.getOriginalData() == null)
							img.setOriginalData(imgb);
						return img;
					} finally {
						if (ra != null)
							ra.close();
					}
				}
			}
			throw new IOException(
					"The byte array is not a recognized imageformat.");
		} finally {
			if (is != null) {
				is.close();
			}
		}
	}
800431
def _readFromUrl(cls, url, writable):
        
        # we use a ~10Mb buffer to improve speed
        with open(cls._extractPathFromUrl(url), 'rb') as readable:
            shutil.copyfileobj(readable, writable, length=cls.BUFFER_SIZE)
431743
function (url, onImageReady, applyAutocrop) {
            var _this = this;

            this.toggleLoadingImage(true);
            this.clear();
            this._applyAutocrop = (applyAutocrop !== false);

            this._image = new IMSoftcrop.Image(
                IMSoftcrop.Ratio.hashFnv32a(url),
                this
            );

            this._image.load(
                url,
                function () {
                    _this.setZoomToImage(false);
                    _this.centerImage(false);
                    _this.updateImageInfo(false);

                    if (_this._autocrop) {
                        _this.detectDetails();
                        _this.detectFaces();
                    }
                    else {
                        _this.toggleLoadingImage(false);
                    }

                    _this.applySoftcrops();
                    _this.redraw();

                    if (typeof onImageReady === 'function') {
                        onImageReady.call(_this, _this._image);
                    }
                }
            );
        }
1294674
def image_url(self):
        """"""
        return construct_api_url(self.input, 'image', self.resolvers, False, self.get3d, False, **self.kwargs)
1253312
public ImageUrlResources imageUrlResources() {
        if (imageUrls.get() == null) {
            imageUrls.compareAndSet(null, new ImageUrlResourcesImpl(this));
        }
        return imageUrls.get();
    }
45305
def post_image(url, filename)
      post(url) do |req|
        req.body = open(filename).read
      end
    end
574778
private BufferedImage downloadImage() throws Exception {
        BufferedImage image = null;
        InputStream in = null;
        try { // first try reading with the default class
            URL url = new URL(imageUrl);

            HttpURLConnection conn = null;

            boolean success = false;
            try {
                conn = (HttpURLConnection) url.openConnection();
                conn.setInstanceFollowRedirects(followRedirects);
                conn.setConnectTimeout(connectionTimeout); // TO DO: add retries when connections times out
                conn.setReadTimeout(readTimeout);
                conn.connect();
                success = true;
            } catch (Exception e) {
                //System.out.println("Connection related exception at url: " + imageUrl);
                //throw e;
            } finally {
                if (!success) {
                    conn.disconnect();
                }
            }

            success = false;
            try {
                in = conn.getInputStream();
                success = true;
            } catch (Exception e) {
                /*System.out.println("Exception when getting the input stream from the connection at url: "
                        + imageUrl);
                throw e;*/
            } finally {
                if (!success) {
                    in.close();
                }
            }
            image = ImageIO.read(in);
        } catch (IllegalArgumentException e) {
            // this exception is probably thrown because of a greyscale jpeg image
            System.out.println("Exception: " + e.getMessage() + " | Image: " + imageUrl);
            image = ImageIOGreyScale.read(in); // retry with the modified class
        } catch (MalformedURLException e) {
            System.out.println("Malformed url exception. Url: " + imageUrl);
            //throw e;
        }
        return image;
    }
1114627
function image(url) {
  url = url.replace(/\??#.*$/, '');
  var inliner = this;
  this.emit('progress', 'get image ' + basename(url));
  return this.get(url, { encoding: 'binary' }).then(function then(res) {
    if (url.indexOf('data:') === 0) {
      return url;
    }

    debug('image loaded: %s', url);

    // if the url is SVG, let's compress and use the XML directly
    if (res.body && mime.lookup(url) === 'image/svg+xml' &&
      !inliner.options.nosvg) {
      return new Promise(function (resolve, reject) {
        svgo.optimize(res.body.toString(), function (result) {
          debug('optimising svg');
          if (result.error) {
            debug('errored', result.error);
            return reject(new Error(result.error));
          }
          // supposing/given:
          // - we are in a CSS single quoted string
          // - this css *may* be in a HTML file, in a <style>
          // - this css *may* be in a HTML file, in a double-quoted attribute
          // - the optimizer possibly replaced:
          //   - & by &amp;  <<< unhandled: add a &amp; in the svg text to test
          //   - ' by &apos;
          //   - " by &quot; (not around attributes)
          // Thus, we have to do a tricky escape pattern
          // ... we use % encoding for html level escape
          // ... we need to use proper \ escape for css level escape
          // ... (or we could have a ' in ' problem (nested sinle quotes))
          // ... so, before anything, we need to escape both \ and %
          var replacements = {
            '<': '%3C',  // html escape
            '"': '%22',  // html escape
            '&quot;': '%22',  // html escape
            '#': '%23',  // css url path escape
            '\n': '\\n', // css string escape
            '\'': '\\\'',// css string escape
            '&apos;': '\\\'',// css string escape
          };
          var body = result.data.replace(/\\/g, '\\').replace(/%/g, '%25')
                     .replace(/[<"#\n']|&quot;|&apos;/g, function (m) {
            return replacements[m];
          });
          resolve('data:image/svg+xml;utf8,' + body);
        });
      });
    }

    // otherwise we base64 encode the image
    return 'data:' + res.headers['content-type'] + ';base64,' +
            new Buffer(res.body, 'binary').toString('base64');

  }).catch(function errorHandle(error) {
    debug('image %s failed to load', url, error);
    throw error;
  });
}
1071605
public static void getBitmapByImageURL(String imageURL, final OnEventListener callback) {

        new DownloadImageTask<Bitmap>(imageURL, new OnEventListener<Bitmap>() {

            @Override
            public void onSuccess(Bitmap bitmap) {
                callback.onSuccess(bitmap);
            }

            @Override
            public void onFailure(Exception e) {
                callback.onFailure(e);
            }
        }).execute();

    }
227437
public static BufferedImage loadImage (InputStream iis, boolean useFastIO)
        throws IOException
    {
        if (iis == null) {
            return null;
        } else if (useFastIO) {
            return FastImageIO.read(iis);
        }
        return ImageIO.read(iis);
    }
392701
function (url) {
            if (this.$.width) {
                url += ",width=" + ImageService.normalizeImageSize(this.$.width);
            }

            if (this.$.height) {
                url += ",height=" + ImageService.normalizeImageSize(this.$.height);
            }

            return url;
        }