image-manipulation

Make an image's background transparent or white programmatically

ぃ、小莉子 提交于 2019-12-05 18:52:14
If one is creating an application in which one would like to make the " background " of an image transparent or white, is there a way to do this? For example : In the image, http://upload.wikimedia.org/wikipedia/commons/b/b9/Bronze_Statuette_of_a_Veiled_and_Masked_Dancer_1.jpg , I would like to transform the image programmatically, such that only the statue remains, and the background (i.e. the rest of the image) is all white, or transparent. Also, the user might point out to the part of the image that should "remain", and the rest should be all white or transparent. How can this be done? Also

How to serve high-resolution imagery in a low-resolution form using C#

廉价感情. 提交于 2019-12-05 16:28:34
Trying to use 300dpi tif images for display on the web. At the moment, when the user uploads an image, I am dynamically creating a thumbnail. If a page is created referencing the high-res image with a width of 500x500px, can I use the same functionality to convert to a gif/jpg on the fly. What is the impending resolution of the jpg that would be created? EDIT: To further explain the usage, the user uploads 300dpi images which are approx 3000x3000 pixels. The user is using these images to create a catalog page which will be used for pdf printing. When they are creating the page, we only need

iPhone JPG image has non-standard magic bytes ff d8 ff e1?

穿精又带淫゛_ 提交于 2019-12-05 13:23:29
My web app checks the first four bytes against the file extension before accepting uploaded images. A coworker showed me images from his iPhone which are being rejected. These have a different fourth byte (e1 = 225 instead of the expected e0 = 224). Is this usual for iPhones? Are there other possible magic byte strings used in JPG files? Edit: found this useful list: http://www.garykessler.net/library/file_sigs.html They seem to indicate a sub category of JPEG in some way. What I have found out is that the FF D8 FF E0 magic indicates a "JFIF JPEG" whereas the FF D8 FF E1 indicates an "EXIF

Saving a modified image to the original file using GDI+

我与影子孤独终老i 提交于 2019-12-05 12:54:41
I was loading a Bitmap Image from a File. When I tried to save the Image to another file I got the following error "A generic error occurred in GDI+". I believe this is because the file is locked by the image object. Ok so tried calling the Image.Clone function. This still locks the file. hmm. Next I try loading a Bitmap Image from a FileStream and load the image into memory so GDI+ doesn't lock the file. This works great except I need to generate thumbnails using Image.GetThumbnailImage method it throws an out of memory exception. Apparently I need to keep the stream open to stop this

Create drop shadow effects in Imagemagick

风格不统一 提交于 2019-12-05 12:16:30
The border shadow effects used in the images of this blog post seem to be embeded in the images themselves (not css3). How can it be created in imagemagick? Edit 1: The solution which I found quite accidentlly is posted below as an answer. There is a -shadow argument on convert that has options to do this. http://blog.bemoko.com/2009/07/01/add-shadow-and-border-to-images-with-imagemagick/ Somehow I found the command which does what I wanted exactly: For images which are already scaled and compressed: convert input.jpeg -bordercolor white -border 13 \( +clone -background black -shadow 80x3+2+2

Checking image feature alignment

北城余情 提交于 2019-12-05 07:03:43
问题 I have written my own software in C# for performing microscopy imaging. See this screenshot. The images that can be seen there are of the same sample but recorded through physically different detectors. It s crucial for my experiments that these images be exactly aligned. I thought the easiest would be to somehow blend/substract the two bitmaps but this doesn't give me good results. Therefore I am looking for a better way to do this. It might be useful to point out that the images exist as

PHP Image Resize & My upload script

别说谁变了你拦得住时间么 提交于 2019-12-05 06:59:38
问题 I have seen a lot of examples, but I am not sure how it can tie into the upload script i currently have. Could someone please explain how I might be able to use ImageMagick or something of the like to resize an uploaded image to a fixed width while keeping the w:h ratio? I have googled and looked at over 150 web pages but none of them really give an example that i feel applies to my situation. Any help would be appreciated. Here is my code: // Include Extension finder function. include_once

Fading a picture gradually

馋奶兔 提交于 2019-12-05 06:42:32
The idea of this function is to fade the top half only of the picture (make it gradually darker). Here is what I have but it seems to be making all of the top half solid black. def fadeDownFromBlack(pic1): w=getWidth(pic1) h=getHeight(pic1) for y in range(0,h/2): for x in range(0,w): px=getPixel(pic1,x,y) setBlue(px,y*(2.0/h)) setRed(px,y*(2.0/h)) setGreen(px,y*(2.0/h)) Let's look at just one line here: setBlue(px,y*(2.0/h)) and key part here is y*(2.0/h) y changes, as you go down. Let's try some simple values for y and h. Let's say h is 100 and we will examine when y is both 0 and 50 (h/2).

Changing the color of an image based on RGB value

给你一囗甜甜゛ 提交于 2019-12-05 05:42:45
Situation: You have an image with 1 main color and you need to convert it to another based on a given rgb value. Problem: There are a number of different, but similar shades of that color that also need to be converted, which makes a simple 'change-all-(0,0,0)-pixels-to-(0,100,200)' solution worthless. If anyone can point me in the right direction as far as an algorithm or an image manipulation technique that would make this task more manageable that'd be great. I've been using PIL to attempt this problem but any general tips would be nice. edit: Also, I've used this other SO answer ( Changing

PHP ImagickDraw with outlined text issues

夙愿已清 提交于 2019-12-05 02:48:29
问题 I'm learning and practicing my Imagick skills. I have issues with outlined text using Imagick stroke. I would like to achieve an effect visible on this image: a popular Internet meme: Here's the code I have so far: $draw = new \ImagickDraw(); $outputImage = new \Imagick('meme.jpg'); $draw->setFillColor('#fff'); $draw->setFont('impact.ttf'); $draw->setFontSize(40); $draw->setGravity(\Imagick::GRAVITY_NORTH); $draw->setStrokeColor('#000'); $draw->setStrokeWidth(1); $draw->setStrokeAntialias