image-manipulation

Reducing the file size of a very large images, without changing the image dimensions

醉酒当歌 提交于 2019-12-02 17:05:10
Consider an application handling uploading of potentially very large PNG files. All uploaded files must be stored to disk for later retrieval. However, the PNG files can be up to 30 MB in size, but disk storage limitations gives a maximum per file size of 1 MB. The problem is to take an input PNG of file size up to 30 MB and produce an output PNG of file size below 1 MB. This operation will obviously be lossy - and reduction in image quality, colors, etc is not a problem. However, one thing that must not be changed is the image dimension. Hence, an input file of dimension 800x600 must produce

PHp - memory error when resizing a PNG image

笑着哭i 提交于 2019-12-02 16:23:26
问题 I have a script that creates a thumbnail out of an uploaded image. it works fine with jpgs, but gives me an error Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 26250000 bytes) when I upload a png image. The script is: //create thumbnail; $modwidth and height are calculated in another part of the script //$original is the path to the full sized image $tn = imagecreatetruecolor($modwidth, $modheight); switch (strrchr($new_image_name,'.')) { case ".jpg": $image

Layer image with opacity over the top of another image. - OpenCV

若如初见. 提交于 2019-12-02 10:45:13
Edit Anybody with a similar problem - I found another SO answer here with a great python solution that exploits the speed of NumPy. Please consider the following problem: I have two images, both the same size. One is a red square with varying layers of opacity: And a second, a blue square, smaller than the red, with no opacity but white surrounding it. I am using OpenCV's python bindings for this project and so far (after reading about watermarking here I have this: redSquare = cv2.imread('redSquare.png', cv2.IMREAD_UNCHANGED) (rH, rW) = redSquare.shape[:2] blueSquare = cv2.imread('blueSquare

How can I check the dimensions of a image so that I can reduce them proportionaly to avoid distortion?

こ雲淡風輕ζ 提交于 2019-12-02 05:49:59
问题 When people write an article, they submit a photo to illustrate the event. But, the space to display is not wide. So, I'd like to reduce they width and/or height while keeping their original proportion. Otherwise, the image gets distorted. Let's say the max width is 300px. Anyting wider than that would see its width reduced to 300px. However, I'd like the Height to be reduced to the same proportion. For instance: 600 x 800 will become 300px x 400px. So, I need to be able to check the

How to resize an image using PHP? [duplicate]

眉间皱痕 提交于 2019-12-02 05:06:31
Possible Duplicate: Resize a picture to a fixed size How to resize an image in PHP? Try the GD and Image functions , or - if you want something more than just that - a library like ImageMagick. You may use imagemagick , call it via exec("convert ...") from php, copy it to the desired location and access it. You can also do like I do and use a lightweight framework like flourishlib.com where everything is nicely wrapped in a class fImage , example from documentation: // Saving as a 60 quality JPEG $image2 = new fImage('./example.gif'); $image2->resize(250, 0); $image2->saveChanges('jpeg', 60);

Resizing BufferedImages and storing them to file results in black background for JPG images

本小妞迷上赌 提交于 2019-12-02 04:44:31
问题 I have the following code: import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; public class JavaApplication { public static void main(String[] args) throws Exception { File orig = new File ("/home/xxx/Pictures/xxx.jpg"); BufferedImage bm1 = ImageIO.read(orig); Image scaled = bm1.getScaledInstance(100, 200, BufferedImage.SCALE_SMOOTH); BufferedImage bm2 = toBufferedImage(scaled); File resized = new File ("

Smart way of resizing images in PHP [closed]

拈花ヽ惹草 提交于 2019-12-02 01:58:34
I was wondering if someone can help me with an image resize function written in PHP but one wich has to resize an image, but in a manner like PHPThumb does. So, if I set the width and height of the new image, the function must fit the uploaded image (and mantain aspect ratio) in the new width and height. Any help is appreciated. Thank you. I wrote this a couple years ago and it does exactly what you're looking for. Keep in mind this only calculates the width and height, you must call Imagick yourself to actually apply these calculations. /** * ImageIntelligentResize() * * @global Intelligently

Printing Bidi text to an image

允我心安 提交于 2019-12-01 19:59:00
问题 I have some code in Python using PIL, that will print UTF-8 characters to an image. I've noticed that for joining Bidi scripts like Arabic, the same code fails to connect characters correctly (the initial forms are only chosen, medial and final forms aren't utilized) Can anyone recommend a method or technique for solving this particular issue? 回答1: If you want to keep using PIL, use pyarabicshaping with pybidi or you might want to consider switching to pangocairo which uses HarfBuzz for text

Printing Bidi text to an image

巧了我就是萌 提交于 2019-12-01 18:22:20
I have some code in Python using PIL, that will print UTF-8 characters to an image. I've noticed that for joining Bidi scripts like Arabic, the same code fails to connect characters correctly (the initial forms are only chosen, medial and final forms aren't utilized) Can anyone recommend a method or technique for solving this particular issue? If you want to keep using PIL, use pyarabicshaping with pybidi or you might want to consider switching to pangocairo which uses HarfBuzz for text shaping. What I did is the following: Python + Wand (Python Lib) +arabic_reshaper(Python Lib) +bidi

BlackBerry - Cropping image

只愿长相守 提交于 2019-12-01 13:04:46
I want to crop a part of Image, for that I am using following code: int x=20; int y=50; int [] rgbdata=new int[(0+width-x+height-y)* (image.getWidth())]; image.getARGB(rgbdata, 0, image.getWidth(), x, y, width, height); cropedImage=new Bitmap(image.getWidth(),image.getWidth()); cropedImage.setARGB(rgbdata, 0,image.getWidth(), 80,80, width, height); x an y are the position from where the cropping will be done in the rectangular form. but it is not working. you can do this using graphics: public Bitmap cropImage(Bitmap image, int x, int y, int width, int height) { Bitmap result = new Bitmap