image-scaling

Canvas inline height and width attributes overridden with css styles. Is this is a bug?

倖福魔咒の 提交于 2019-12-01 23:05:14
问题 I recently asked a question on how to draw an image larger than my canvas onto the canvas without cropping and save the image back into its original dimensions after performing some changes on it. I found the solution is to set the inline height and width attributes for the canvas larger than the image, and use css height and width properties to style the canvas to fit into your layout. For example, assuming my images could range between 400px to 2000 px in dimensions. But I don't want the

Canvas inline height and width attributes overridden with css styles. Is this is a bug?

限于喜欢 提交于 2019-12-01 20:42:57
I recently asked a question on how to draw an image larger than my canvas onto the canvas without cropping and save the image back into its original dimensions after performing some changes on it. I found the solution is to set the inline height and width attributes for the canvas larger than the image, and use css height and width properties to style the canvas to fit into your layout. For example, assuming my images could range between 400px to 2000 px in dimensions. But I don't want the canvas to be so big, and I don't want the images to be cropped as well (because when saving the image

Scaling Part of a Picture

China☆狼群 提交于 2019-12-01 01:27:47
I want to scale up a part of a picture, in this example, a nose. I have a function to select the part of the picture I want to enlarge. def copyAndPaste(picture): height = getHeight(picture) width = getWidth(picture) newPicture = makeEmptyPicture(width, height) for x in range(width): for y in range(height): pxl = getPixel(picture,x,y) if (x>48 and x<59) and (y>58 and y<71): newPxl =getPixel(newPicture, #?,#?) else: newPxl = getPixel(newPicture, x,y) color = getColor(pxl) setColor(newPxl,color) return newPicture def d(): f=pickAFile() picture=makePicture(f) newPicture = copyAndPaste(picture)

JSP How to scale an image?

こ雲淡風輕ζ 提交于 2019-11-30 21:36:45
Is there anyway to scale an image then display in jsp page? When retrieve and display the images, I want to show all photos in same size. is there any API can do it? I have searched from google, those I found was about scaling images byusing tookit but can't works in web application. You can use the builtin Java 2D API for this (basic Sun tutorial here ). Basically, you need to create a Servlet which gets an InputStream of the original image in the doGet() method, passes it through the Java 2D API and then writes it to the OutputStream of the HTTP response. Then you just map this Servlet on a

Create thumbnail and reduce image size

橙三吉。 提交于 2019-11-30 12:18:24
问题 I have very large images (jpg) and i want to write a csharp program to loop through the files and reduce the size of each image by 75%. I tried this: Image thumbNail = image.GetThumbnailImage(800, 600, null, new IntPtr()); but the file size is still very large. Is there anyway to create thumbnails and have the filesize be much smaller? 回答1: private void CompressAndSaveImage(Image img, string fileName, long quality) { EncoderParameters parameters = new EncoderParameters(1); parameters.Param[0]

HTML img scaling

两盒软妹~` 提交于 2019-11-30 10:36:39
问题 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

Scale image according a maximum file size

核能气质少年 提交于 2019-11-30 09:51:45
问题 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

Css changing aspect ratio of fluid images

瘦欲@ 提交于 2019-11-30 07:41:23
问题 How can I crate a fluid image, but with an aspect ratio that I decide? (lets say 16:9) I've already made it fluid with max-width: 100%; but I cant change the aspect ratio. Note: the image has a different aspect ratio most of the times. 回答1: You can wrapp your image in two containers. Give one container height:0 and a padding-top with the percentage you want for the height of your image in proportion to the width. So, for a height of 50% of the width use padding-top:50% and height:0 , which -

JSP How to scale an image?

牧云@^-^@ 提交于 2019-11-30 05:43:52
问题 Is there anyway to scale an image then display in jsp page? When retrieve and display the images, I want to show all photos in same size. is there any API can do it? I have searched from google, those I found was about scaling images byusing tookit but can't works in web application. 回答1: You can use the builtin Java 2D API for this (basic Sun tutorial here). Basically, you need to create a Servlet which gets an InputStream of the original image in the doGet() method, passes it through the

Scale a BufferedImage the fastest and easiest way

主宰稳场 提交于 2019-11-30 04:54:44
The task: I have some images, I scale them down, and join them to one image. But I have a little problem with the implementation: The concrete problem: I want to resize/scale a BufferedImage. The getScaledInstance method returns an Image object, but I can't cast it to BufferedImage: Exception in thread "main" java.lang.ClassCastException: sun.awt.image.ToolkitImage cannot be cast to java.awt.image.BufferedImage (I don't know why is it a ToolkitImage instead of an Image...) I found a solution: Image tmp = bi.getScaledInstance(SMALL_SIZE, SMALL_SIZE, BufferedImage.SCALE_FAST); BufferedImage