AppleScript-Droplet: convert image to monochrome / grayscale / black&white

Hello,
i am used to applescript itself and now willing to write me a small droplet which converts dropped images (jpg & png) to grayscale images.
right now i am wondering which might be the best application i could use for that ?
First ideas was ImageMagick (somehow special ...macports) or Sips.
Is there any chance that i can use a more usual application like Preview from applescript to do the convert task ?
any ideas ?
Best regards
fidel

Hi Piere,
that looks great - i added the applescript/keystroke part for save & quit and the result is perfect for my needs.
My mistake was to just check the offered options in automator - ignoring the keystroke possibilities.
Thanks once again
Best regards
fidel
code:
on open droppedImages
tell application "Preview"
activate
repeat with currentImage in droppedImages
open currentImage
tell application "System Events"
keystroke "c" using {option down, command down}
tell process "Preview"
set value of value indicator 1 of slider 2 of window 1 to 0
-- other image modifications are possible here
end tell
end tell
end repeat
tell application "System Events" to tell process "Preview" to click button 1 of window 1
-- save
tell application "System Events"
keystroke "s" using command down
end tell
-- quit preview
quit
end tell
end open

Similar Messages

  • Feature Request: Monochrome / Grayscale / Black & White

    We have an iPad, and bought an AirPrint capable printer. Printing works fine, and set up was a breeze.
    Most of what is printed is black and white text from emails, and it would be fantastic if on the print screen a toggle was made for color vs (black and white / monochrome / grayscale) printing.
    I don't think it would be that big of a deal, as it is a feature that every printer driver should have already (as opposed to duplexing - which is also a good feature to add).
    Is this in the pipleline as a feature? Either way, reply to this post and maybe it could be a priority.
    Message was edited by: dgravenor

    Not something we can help you with.
    You can submit it here: http://www.apple.com/feedback/

  • Convert image from color to black&white

    Hi,
    I'd like to transform a colored picture (from a gif or jpeg file for
    exemple) in a Black and White image (wbmp format). I use a
    ColorConvertOp to do that, but I don't know how to param it to have a nice
    conversion, not a pixel level conversion. Here is the code I used:
    BufferedImage bi4 = new BufferedImage(bi3.getWidth(), bi3.getHeight(),
    BufferedImage.TYPE_BYTE_BINARY);
    ColorConvertOp cco2 = new
    ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
    cco2.filter(bi3, bi4);
    Where bi3 is my original BufferedImage.
    Do you know where I can find more information on this conversion, because in
    the help I don't understand everything (I have no knowledge on picture
    conversion)?
    Thanks for all
    Vincent

    Try this example
    regards
    Stas
    import javax.swing.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    public class Test {
    JScrollPane scroll;
    JEditorPane edit=new JEditorPane();
    public Test() throws Exception {
    JFrame frame=new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    BufferedImage sourceImage=new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);
    Graphics g=sourceImage.getGraphics();
    g.setColor(Color.red);
    g.fillRect(0,0,100,100);
    g.setColor(Color.blue);
    g.fillRect(10,10,80,80);
    g.setColor(Color.yellow);
    g.fillRect(20,20,60,60);
    g.setColor(Color.white);
    g.drawString("test",5,15);
    frame.getContentPane().add(new JLabel(new ImageIcon(sourceImage)));
    BufferedImage grayImage=new BufferedImage(100,100,BufferedImage.TYPE_BYTE_GRAY);
    grayImage.getGraphics().drawImage(sourceImage,0,0,null);
    frame.getContentPane().add(new JLabel(new ImageIcon(grayImage)),BorderLayout.SOUTH);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.show();
    public static void main(String[] args) throws Exception {
    new Test();

  • Converting part of an image to Grayscale (black & white)

    Q. I want to make part of an image grayscale but keep some color elements.
    Answer: There is always more than one way to do something in Photoshop.
    #1 Select the area you want to be grayscale. Create a new Hue/Saturation Adjustment Layer (half-moon icon in the Layers palette). Dial down the Saturation.
    #2 Make a copy of your image and make it Grayscale.
    After creating a layer in the color image with just the part of your image you want to still be color paste the Grayscale image under this layer.
    Your image will still be a color image with elements that look grayscale.
    #3 In CS3 (version 10 ) use Image > Adjustments > Black & White

    It's all virtual right now. Various issues keep the points from being displayed, but it does contribute to the "level" setup which at some point will function (I'm guessing) much like the "old system" where you get certain bonuses (personal avatars, etc) depending on the "level" you are in the system.
    I'm already a level 4, so points only contribute to my "reputation", I guess. But TPTB have suggested that we inform users of the Forum on the proper way to use it to build a better community.
    Thanks for the "Solved"
    Patrick

  • Image convert from jpg to BMP (black & white)

    Hi everybody
    here i am converting a jpg file to 2 bit monochrome image.
    Though this program is making the bmp monochrome image of passing jpg image.
    but the program is hanged in between.
    I don't understand the why it is hanging..though it is generating the result.
    please help me to solve the hanging problem.
    =================================================================================
    source output is:
    C:\j2sdk1.4.1_02\bin>java jaiexp.JAISampleProgram6 aish5.jpg
    1
    2
    FarmHouse2.bmp image
    ERROR: it doesn't finish gracefully....!!
    ==================================================================================
    source code
    package jaiexp;
    import java.awt.Frame;
    import java.awt.image.renderable.ParameterBlock;
    import java.io.IOException;
    import javax.media.jai.Interpolation;
    import javax.media.jai.JAI;
    import com.sun.media.jai.codec.BMPEncodeParam;
    import javax.media.jai.RenderedOp;
    import com.sun.media.jai.codec.FileSeekableStream;
    import javax.media.jai.widget.ScrollingImagePanel;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.image.renderable.*;
    import javax.media.jai.*;
    import javax.media.jai.widget.*;
    import com.sun.media.jai.codec.*;
         * This program decodes an image file of any JAI supported
         * formats, such as GIF, JPEG, TIFF, BMP, PNM, PNG, into a
         * convert it to BMP and save it as bmp file
         public class JAISampleProgram6 {
              /** The main method. */
              public static void main(String[] args) {
                   // Define the source and destination file names.
                   String outputFile = "C:\\j2sdk1.4.1_02\\bin\\jaiexp\\FarmHouse2.bmp";
                   Image bwImage = null;
                   /* Validate input. */
                   if (args.length != 1) {
                        System.out.println("Usage: java JAISampleProgram " + "input_image_filename");
                        System.exit(-1);
                   }//if ends
                   * Create an input stream from the specified file name
                   * to be used with the file decoding operator.
                   Image colorImage = null;
                   try {
                        colorImage = Toolkit.getDefaultToolkit().createImage(args[0]);
                   } catch (Exception e) {
                        e.printStackTrace();
                        System.exit(0);
                   }//try catch ends
                   ImageFilter filter = new BlackWhiteFilter();
                   ImageProducer producer = new FilteredImageSource(colorImage.getSource(),filter);
                   bwImage = Toolkit.getDefaultToolkit().createImage(producer);
                   // Create the ParameterBlock.
                   ParameterBlock pb = new ParameterBlock();
                   pb.add(bwImage);
                   // Create the AWTImage operation.
                   //PlanarImage im = (PlanarImage)JAI.create("awtImage", pb);
                   RenderedOp image1 = (RenderedOp)JAI.create("AWTImage", pb);
                   System.out.println("1");
                   try {
                        FileOutputStream stream = new FileOutputStream(outputFile);
                        System.out.println("2");
                        javax.media.jai.operator.EncodeDescriptor.create(image1,stream,"BMP",null,null);
    System.out.println("3");
                        javax.media.jai.operator.FileStoreDescriptor.create(image1,outputFile,"BMP",null,null,null);
                        System.out.println("4");
                        stream.close();
                   }catch(Exception e){
                        System.out.println("Error:"+e);
                   }//try catch ends
                   System.out.println("5");
              }//fun ends
         }//class ends
         class BlackWhiteFilter extends RGBImageFilter{
         public int filterRGB(int x, int y, int rgb){
         int alpha = (rgb >> 24) & 0xff;
         int red = (int)(((rgb >> 16) & 0xff) * 0.3f);
         int green = (int)(((rgb >> 8) & 0xff) * 0.59f);
         int blue = (int)((rgb & 0xff) * 0.11f);
         int bws = ((red+green+blue) > 127) ? 255 : 0;
         return ((alpha & 0xFF) << 24) | ((bws & 0xFF) << 16) | ((bws & 0xFF) << 8) | ((bws & 0xFF) << 0);
         }//class ends
    thanks in advance.
    regards
    - Deepak
    email: [email protected]
         

    Also keep in mind that there are two definitions of bitmap. You want the 2-color version where each bit represents one color or the other. However, thanks to Microsoft, their bitmaps are really just uncompressed strings of RGB values, storing each pixel in multiple bits.

  • Converting jpgs of documents to black & white pdfs

    Any help is greatly appreciated!
    Long story short - I can provide more details if necessary - I have a collection of jpg files that are pictures of documents - no images - that I had to take to copy them instead of zeroxing them.  I am trying to convert them into pdfs that are:
    1.) as black and white as possible so as to make it as close to printing a regular black and white word document as possible (instead of using a lot of printer ink on printing pictures that just happen to be saved in pdf format), and
    2.) searchable vis-a-vis OCR.
    After a recommendation from a teacher, I purchased Adobe Acrobat a few days ago which I've never used before.  That being said, I can convert them into pdfs, I can make them searchable because I've played around with the OCR and that seems pretty straight forward.
    However, no matter how many times I try, no matter how many different preferences/settings/etc. I play around with (as an aside, how the hell do I revert these settings back to default?  I can't remember what they all were beforehand!), I can't get the pdfs to look like anything other than the same jpg image but now saved as a pdf.
    I've also been recommended ABBYY FineReader, and I've tried that as well and it seems to do a much better job, unless I'm missing something.
    I'd share the documents, but I can't figure out how.
    EDIT:  After uploading pdfs to acrobat.com, taking 30 mins to get workspaces to open up, but then not being able to transfer the documents from acrobat.com to workspaces, I finally uploaded them again from my desktop to workspaces - WHY IS THIS SO DIFFICULT?!?!
    So my questions basically is this:  How do I get adobe to make files like this:
    https://acrobat.com/?d=KJskXucbh2pBBPuZmsL6Hw
    look like this:
    https://acrobat.com/?d=RrXBupJrVFQBKNT*DdqK5g
    This has been a very frustrating day.  Any help is appreciated.

    Thanks to everyone who has responded to my questions, but I have decided to return Acrobat Pro and stick with ABBYY FineReader.
    Perhaps I'm misunderstanding your responses, but I can't help but feel as if either nobody here is able to see the differences between the two pdfs I link to above, or nobody here believes me when I say that the jpeg file (link above) I used to create the pdf with ABBYY (link above) was the same jpeg file I used to create the pdf  with Acrobat (link above).
    Instead, the consensus seems to be that the only way I could have possibly created the kind of perfect-looking black and white (or monochrome or whatever) pdf that I made with ABBYY (as opposed to pdfs Acrobat makes, which look and print exactly like the jpeg images but with various grey filters applied to it) was by using a scanner, a perfectly flat document, and maybe even graphics editing software.
    None of these are needed because that isn't the issue here.  I wasn't allowed to use a scanner anyway as is often the case when digitizing documents from a university's library archives. 
    The only thing you need to do is not use Acrobat but use ABBYY FineReader 11 instead.  FineReader was not only able to convert the jpegs (despite the fact the jpegs were made not with a scanner but a webcam that was propped above the document) into pdfs that looked like the one above, but did so unbelievable easy - simply by selecting the black and white mode option before the conversion.
    Again, I appreciate everyone who took the time to read and respond to my questions, and perhaps in the field of pdf conversion and creation what I'm asking to do isn't often done or in high demand, which may perhaps be why Acrobat can't do it.  Admittedly even on ABBYY's software this black and white mode is a brand new feature.  Nevertheless, the fact that ABBYY's software can do this so easily, even with imperfectly taken jpeg files, AND produce OCR that is more accurate that Acrobat's, all for less than half of Acrobat's cost, I can't help but question why Adobe can't get their feature-laden, labyrinthian software to do this, especially for 450 bucks.
    Also, with all due respect, when someone is asking if acrobat can do something with already-existing files (that couldn't be made with a scanner) that a similar software can do with those same files, responding by suggesting that they throw out the files they already made and have to use, go back and recreate new files in a way that was already determined to be unavailable is both unhelpful and a bit frustrating, especially you come off in your suggestions as seeming to ignore or disbelieve that the other standalone software actually did this in the first place.
    Thanks again for everyone's time, and I hope this thread is of some use in the future to anyone trying to do what I'm doing now.

  • Convert color images to black&white bitmaps

    Hi,
    I have black&white scans of public domain books (image format). I use an OCR software to convert them to indexable PDFs (image+text format). However, the OCRed PDFs are insanely big: a 27 MB scanned PDF leads to an indexable PDF of 728 MB! And unfortunately, my OCR software doesn't have output settings, so I have to find a way to compress the files using Adobe Acrobat 9 Pro.
    Using Advanced Options > Optimization does reduce the file size, but not significantly. The problem seems to be that my OCR software converts the black&white scans to color images, and encodes them as such inside the PDF. So I need a way to set the image modes back to black&white. I tried using the Advanced Options > Preflight dialog, and selecting "Convert to black&white". However, the resulting PDFs stay about the same size! It seems that "Convert to black&white" converts the images to grayscale, instead of to bitmap.
    Any help would be appreciated!

    I mentioned "bitmaps", because when I open the original PDF and right-click a random page and select "Modify image..." and open the image in Photoshop, the mode is set to "Bitmap mode": meaning 1-bit mode, containing either black or white pixels. However, when I do "Modify image..." for the OCRed PDF, the mode is set to "RGB Color Mode". I think this explains, in part, the huge size of the OCRed PDF.
    Maybe this table will make it more clear:
    Original PDF (Bitmap Mode, 132 dpi)
    Size: 27 MB
    OCRed PDF (RGB Color Mode, 300 dpi)
    Size: 728 MB
    Now, from the table above, it's clear that I have to reduce the image resolution. So, using the Acrobat's PDF optimizer, I tried the following settings:
    Optimized OCRed PDF: Try 1 (Downsample to 132 dpi, JPEG compression)
    Size: 733 MB
    Optimized OCRed PDF: Try 2 (Downsample to 132 dpi, ZIP compression)
    Size: 449 MB
    But 449 MB is still huge for a single book. And I don't want to reduce the resolution under 132 dpi, because I will loose quality. Clearly, if the original document is just 27 MB, I should be able to squeeze the OCRed document too. But I don't know how.

  • Printer regonizes Black/white page as color page

    When we print a Word document to a PDF file with the Acrobat printer, pages that contain only Black/White information but with an image that looks as if it is Black/White, the printer recognizes the page as a color page. When we print this page with Word directly to the printer, the page is recognized as a Black/White page.
    Are there color setting available which control the setting for gray scale images to be printed Black/White?

    Leo,
    choose for default settings a joboption set which
    contains for output
    Settingsfile: None
    Color Management: Leave Color Unchanged (!)
    Results:
    Source sRGB (color): PDF color 3x8 bits
    OK
    Source Grayscale: PDF gray 1x8 bits (Indexed)
    OK
    Source sRGB (gray) with R=G=B: PDF gray 1x8bits (Indexed)
    Very wrong.
    This is a well known bug in the Acrobat software:
    http://www.adobeforums.com/webx/.59b641a5
    Best regards --Gernot Hoffmann

  • Black & white and Sepia effects

    Hi, I have iPhoto 5 (version 5.0.4) and would like to convert original photos to either Black & White or Sepia. Can I do this in this version? I don't seem to have those options when I select a photo to start editing it. thanks :o)

    Leggy1
    Welcome to the Apple Discussions.
    It’s quite a while since I used v5 but I think you’ll need a later version to do this. Or you can use an external editor:
    In order of price here are some suggestions:
    Seashore (free)
    Graphic Coverter ($45 approx)
    Acorn ($50 approx)
    Photoshop Elements ($75 approx)
    There are many, many other options. Search on MacUpdate.
    You can set Photoshop (or any image editor) as an external editor in iPhoto. (Preferences -> General -> Edit Photo: Choose from the Drop Down Menu.) This way, when you double click a pic to edit in iPhoto it will open automatically in Photoshop or your Image Editor, and when you save it it's sent back to iPhoto automatically. This is the only way that edits made in another application will be displayed in iPhoto.
    Regards
    TD

  • Converting grayscale to black & white

    I have a sketched out map of a parking lot that I want to convert to a true black and white. Can someone please tell me step by step how to do this?
    Thanks...

    Curvemeister told you how to convert from RGB to grayscale. And by the way I think the new(ish?) black and white adjustment layer does your trick in one adjustment. Please correct me if I'm wrong.
    Max:
    To move from grayscale to "true black and white" (bitmap), you can use the layer...new adjustment layer...threshold and move the slider. Personally, I like to upsample the image some, as bitmaps have no gray tones to smooth lines out. Your target resolution should be 450-600 ppi at the size you will print. Of course, you can go higher... You can upsample using bicubic smoother and then use the threshold adjustment layer. When you're happy with how it looks, just image...mode...bitmap it and you've got a true black and white.
    Of course if your image is photographic, you might want to turn it into "line art," which is kind of a different thing. If you try the threshold adjustment layer on a photo, you'll see what I mean.
    Be sure to save as, or dupe the file before you begin!
    J

  • Preserving alpha while converting images to grayscale

    I am trying to convert images into grayscale.
    I use this code
    public static BufferedImage grayScale(BufferedImage im) {
            BufferedImage image = new BufferedImage(im.getWidth(), im.getHeight(), BufferedImage.TYPE_BYTE_GRAY);
            Graphics g = image.getGraphics();
            g.drawImage(im, 0, 0, null);
            g.dispose();
            return image;
        }but transparent parts become black. Is there a simple way to preserve opacity while converting to grayscale.

    Since you want to preserve the alpha channel you'll need to get and set the pixels yourself. And you'll have to use a BufferedImage type that
    supports an alpha channel. TYPE_BYTE_GRAY won't do...
    public static BufferedImage grayScale(BufferedImage im) {
         BufferedImage grayImage = new BufferedImage(im.getWidth(), im.getHeith(), BufferedImage.TYPE_INT_ARGB);
         for(int x = 0; x < im.getWidth(); x++)
              for(int y = 0; y < im.getHeight(); y++){
                   int argb = im.getRGB(x,y);
                   int a = (argb >> 24) & 0xff;
                   int r = (argb >> 16) & 0xff;
                   int g = (argb >>  8) & 0xff;
                   int b = (argb      ) & 0xff;
                   int l= (int) (.299 * r + .587 * g + .114 * b) //luminance
                   grayImage.setRGB(x,y, (a << 24) + (l << 16) + (l << 8) + l);
         return grayImage;
    }

  • URGENT - how do I convert and image from colour to black and white?

    Hi,
    I'm new to Java, and I really need some code to convert an image from colour to black and white! I would really appreciate any help, but since I don't know much about Java I would prefer some code or links to websites with the code.
    Thanks!!!

    http://forum.java.sun.com/thread.jsp?forum=5&thread=368759

  • Applescript droplet in xcode: convert "names" to strings

    Hi,
    i am trying to do a small applescript droplet in xcode.
    [quote]
    the default script in xocde looks like this:
    +on idle+
    +-- add your script here+
    +end idle+
    +on open names+
    +-- add your script here+
    quit
    +end open+
    [/quote]
    i was trying to display the name of the file i have draged to my droplet in a dialog.
    so my idea was like this:
    [quote]
    +set foo to string value of names+
    +display dialog foo+
    [/quote]
    The source compiles without problems but if i drag a file to my droplet the displayed dialog looks somehow wrong.
    [quote]
    +AppleScript Error+
    +Can’t get «class texD» of {alias "MYHD:Users:me:Desktop:test 1.png"}. (-1728)+
    [/quote]
    Any idea what i am doing wrong here ?
    null

    Try using:
    name of (info for names)
    or if you've dragged multiple items:
    set the_string to ""
    repeat with this_item in names
    set the_string to the_string & name of (info for this_item) & return
    end repeat
    (30592)

  • Converting a PDF to pure black and white

    I'm currently attempting to convert a PDF of any colorspace (RGB, CMYK, Grayscale etc) to black and white.
    Currently I'm walking the PDF using Adobe PDFLibrary, separating the contained PDEElements and identifying them (Image, text, etc).
    Does anyone have any advice on how to proceed from here? I figure the actual conversion operation will have to be written from scratch, as Adobe doesn't seem to support this. However, I'm having a hard time determining the colors of each object. I suppose I could rasterize everything and convert pixel by pixel, but I'd like to avoid that and preserve vector images and such if at all possible.
    Thanks in advance for any help!

    Yes, I'm aware that there is no monochrome colorspace. However, wouldn't it be possible (likely at a very low level) to fetch and modify the colors of elements manually?
    I suspect the initial thing to do is convert images to the DeviceGray colorspace and work from there, so I have a uniform colorspace to work with when performing this operation.
    I've noticed that if I pull the ImageData object out of a PDEImage, I get an array of bytes that appear to be pixel by pixel color data. Now, in doing this have I rasterized the image? What would happen to vector images if this array were to be modified?

  • How can I convert RGB Color to Black-White Color?

    Dear everyone!
    I am using Photoshop CS5. I have got a file from my customer which is done as RGB and the resolution is 300dpi. There are black texts and color images in the file. I wish to print Black-White Process Film (1 black color), but I don't know how to solve it. I started converting my file to Grayscale and then the black texts are not black enough because it becomes lighter. When I go to Level and adjust the color, both the image and texts becomes darker. What must I do to make only texts blacker without effecting the image?
    Please find the attached file for the reference.
    For more information, please let me know.
    My Best Regards,
    LUCK

    luck_lesson wrote:
    ...I have got a file from my customer which is done as RGB and the resolution is 300dpi. ..
    What file format was supplied to you? Was it truly RGB @ 300ppi or did you rasterize a PDF?
    300ppi is lousy for text. You might converse with your customer to instruct them on the ideal way to supply a file to you.

Maybe you are looking for

  • Digial Filing, Scan to Network Folder not working on new Asus Windows 8.1 laptop

    I've having difficulty setting up Digital Filing, Scan to Network Folder on my new Asus Windows 8.1 laptop. I'm using a HP Officejet Pro 8500 A909g Series. It seems to setup correctly with no errors. However, all scans end up with a zero file size PD

  • ITunes Library Error - Help Please

    Hi All, I'm new to this forum and have only had my iPhone 4 for a handful of weeks now. I'm running the latest iTunes software on Windows XP and all has been fine till this morning....I went to open up iTunes and got a message to say that the iTunes

  • Adobe reader 9.0 + Adobe Acrobat 5.0 on Internet explorer 7.0 ?

    Hello! I possess Adobe Acrobat 5.0 to create some PDF documents I possess Adobe Reader 9.0 to read some PDF The 2 programs operate WindowsXP SP3 well. I don't manage to open a PDF file with Internet Explorer 7.0 = he looks for has open Acrobat instea

  • Error when using Weblogic Http PubSub

    Hi, I am using Weblogic 10.3 with Weblogic Http PubSub with JMS. Weblogic doesn't start if configuration file WEB-INF/weblogic.xml contains the following tag: <wls:container-descriptor>      <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classe

  • Building Business Area through Command Line

    Hi -- Some of the adminstrator tasks such as... 1) Creating a folder 2) Creating a join 3) Creating a item class and attaching the item class to a filed I would like to do these tasks eighter programtically (via PL/SQL) or through a command line scri