image-scaling

How to scale an image (in data URI format) in JavaScript (real scaling, not using styling)

天涯浪子 提交于 2019-11-30 03:59:35
We are capturing a visible tab in a Chrome browser (by using the extensions API chrome.tabs.captureVisibleTab) and receiving a snapshot in the data URI scheme (Base64 encoded string). Is there a JavaScript library that can be used to scale down an image to a certain size? Currently we are styling it via CSS, but have to pay performance penalties as pictures are mostly 100 times bigger than required. Additional concern is also the load on the localStorage we use to save our snapshots. Does anyone know of a way to process this data URI scheme formatted pictures and reduce their size by scaling

Python / Pillow: How to scale an image

六月ゝ 毕业季﹏ 提交于 2019-11-29 23:54:51
Suppose I have an image which is 2322px x 4128px. How do I scale it so that both the width and height are both less than 1028px? I won't be able to use Image.resize ( https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.resize ) since that requires me to give both the new width and height. What I plan to do is (pseudo code below): if (image.width or image.height) > 1028: if image.width > image.height: tn_image = image.scale(make width of image 1028) # since the height is less than the width and I am scaling the image # and making the width less than 1028px, the height

HTML img scaling

南笙酒味 提交于 2019-11-29 21:59:12
I'm trying to display some large images with HTML img tags. At the moment they go off the edge of the screen; how can I scale them to stay within the browser window? Or in the likely event that this is not possible, is it possible to at least say "display this image at 50% of its normal width and height"? The width and height attributes distort the image -- as far as I can tell, this is because they refer to whatever attributes the container may end up with, which will be unrelated to the image. I can't specify pixels because I have to deal with a large collection of images each with a

Scale image according a maximum file size

半城伤御伤魂 提交于 2019-11-29 16:44:07
I'm using Imagick and like to scale an image to a maximum file size of 2.5MB I had a look to this SOF question: ImageMagick: scale JPEG image with a maximum file-size which is exactly what I want to do but the extent() method from Imagick does not have the size parameter: http://www.php.net/manual/en/imagick.extentimage.php Anyone knows how I could to it? At the moment I'm trying to calculate a coefficient between the original file size and the target file size to calculate a new resolution but found out that the resolution is not proportional to the file size. Update - The output format is

JavaFX : Image getting scaled to 25% and then getting printed.

廉价感情. 提交于 2019-11-29 12:57:13
I am trying to print an image using JavaFX api's. Unfortunately, it is cutting a part of the image, approximately 25% and then stretching that to the entire A4 page, and printing it. What am I doing wrong with the print code. How can I instruct to fit the image to page for printing, no matter what the printer is. Kindly let me know. Code : public void printThis() { System.out.println("I was called"); // note you can use overloaded forms of the Image constructor // if you want to scale, etc String path = "resources/img/printouts/image.png"; Image image = new Image(getClass().getResource(path)

dynamically scale images in php jpg/png/gif

◇◆丶佛笑我妖孽 提交于 2019-11-29 08:10:13
Is there a simple way of dynamically scaling an image in php? Id like to specifically use some kind of function where i can insert it into my heml such as <img src=image.php?img=boss.jpg&width=500> and of course it would then scale the image to whatever height constrains it to 500px wide i appreciate all input, thanks. EDIT does need to include jpg png and gif file types I prefer WideImage library, because it's really really easy to use. In your case, everything you have to do is: $img_path = $_GET['img']; $new_width = $_GET['width']; $new_img = wiImage::load($img_path)->resize($new_width);

What is the best way to scale images in Java?

依然范特西╮ 提交于 2019-11-29 07:38:41
问题 I have a web application written in Java (Spring, Hibernate/JPA, Struts2) where users can upload images and store them in the file system. I would like to scale those images so that they are of a consistent size for display on the site. What libraries or built in functions will offer the best results? I will consider the following criteria in making my decision (in this order): Free/Open Source (essential) Easy to implement Quality of results Performance Size of executable 回答1: Have a look at

Bilinear image interpolation / scaling - A calculation example

北慕城南 提交于 2019-11-29 02:56:44
问题 I would like to ask you about some bilinear interpolation / scaling details. Let's assume that we have this matrix: |100 | 50 | |70 | 20 | This is a 2 x 2 grayscale image. Now, I would like scale it by factor of two and my matrix looks like this: | 100 | f1 | 50 | f2 | | f3 | f4 | f5 | f6 | | 70 | f7 | 20 | f8 | so if we would like to calculate f4 , the calculation is defined as f1 = 100 + 0.5(50 - 100) = 75 f7 = 70 + 0.5(20 - 70) = 45 and now finally: f4 = 75 + 0.5(45 - 75) = 60 However, I

Java - I need a very fast image scaling algorithm

浪子不回头ぞ 提交于 2019-11-28 21:40:27
I am working on a Midlet application. I am finding myself in the need to scale images very often. This has become a problem because some phones are pretty slow and scaling takes too long. Currently I'm using Image.createRGBImage(int, int, int, boolean) to scale the image. I was wondering if any of you knew of a very efficient and fast way to scale an image. Note: this is a Midlet application so only JavaME is available, meaning I don't have access to some other libraries available in the full java version. Note2: most of my scaling is done from small to large images, although I also do scale

Python / Pillow: How to scale an image

送分小仙女□ 提交于 2019-11-28 20:56:45
问题 Suppose I have an image which is 2322px x 4128px. How do I scale it so that both the width and height are both less than 1028px? I won't be able to use Image.resize (https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.resize) since that requires me to give both the new width and height. What I plan to do is (pseudo code below): if (image.width or image.height) > 1028: if image.width > image.height: tn_image = image.scale(make width of image 1028) # since the height is