Results 1 to 11 of 11
  1. #1
    orion_mcl is offline Member
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    Default Opening an image in Photoshop from a Java program

    Hi everybody! I'm developing a program to manage an image listing, so, when the user has found the image that he was looking for he needs to open this image in Photoshop. How can I do this?

    I found this solution in Delphi:

    ShellExecute(Handle, 'Open', 'Photoshop', pchar('C:\imagen.jpg'), nil, SW_SHOW);

    Is there a Java equivalent?

    Please help me.

    P.D.: Sorry for my English, I'm learning it too. :o

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,227
    Rep Power
    6

    Default

    The ProcessBuilder class allows you to execute commands from the command line. So if you know how to invoke Photoshop and load a file from the command line you should be able to do the same in java.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    And also read bit more about Process class as well. It's helpful to have a clear idea about the ProcessBuilder usages. Start from the simple step, try to start the photoshop through the Java application first. There is an exe/executable for the photoshop, try to start that through the Java code. In next step think about that how you can pass more details (image name as your requirement...) to the process.

  4. #4
    atom86 is offline Member
    Join Date
    Sep 2009
    Location
    Italy, Turin
    Posts
    39
    Rep Power
    0

    Default

    Setting photoshop as the defult program to open images.. and use Desktop class? could be a solution?

    you'll need just to call

    desktop.open("[...]img.jpg");

    perhaps in this situation it's much simpler than process builder...and you can get the same result...

  5. #5
    orion_mcl is offline Member
    Join Date
    Aug 2007
    Posts
    17
    Rep Power
    0

    Default

    Hi! Thank you for your answers. I've tried to open an image from the command line with the following:

    c:/.../PhotoShop.exe "c:/image.jpeg"

    I think this is the most common way to specify a file as parameter for an exe but this just opens PhotoShop and not the image.

    Thank in advance.

  6. #6
    atom86 is offline Member
    Join Date
    Sep 2009
    Location
    Italy, Turin
    Posts
    39
    Rep Power
    0

    Default

    Quote Originally Posted by orion_mcl View Post
    Hi! Thank you for your answers. I've tried to open an image from the command line with the following:

    c:/.../PhotoShop.exe "c:/image.jpeg"

    I think this is the most common way to specify a file as parameter for an exe but this just opens PhotoShop and not the image.

    Thank in advance.


    with my solution you can open photoshop with the image you want.... but you discarded my solution without any explanation.....

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by atom86 View Post
    Setting photoshop as the defult program to open images.. and use Desktop class? could be a solution?

    you'll need just to call

    desktop.open("[...]img.jpg");

    perhaps in this situation it's much simpler than process builder...and you can get the same result...
    For me, changing the default program is not a good idea. I don't think any customer like that feature. What you think?

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by orion_mcl View Post
    Hi! Thank you for your answers. I've tried to open an image from the command line with the following:

    c:/.../PhotoShop.exe "c:/image.jpeg"

    I think this is the most common way to specify a file as parameter for an exe but this just opens PhotoShop and not the image.

    Thank in advance.

    Think that, you execute the executable, and exe for photoshop. But how that executable take external information? How to pass parameters to the application basically.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by atom86 View Post
    with my solution you can open photoshop with the image you want.... but you discarded my solution without any explanation.....
    No worries lol, he'll tryout your solution as well. I'm sure about that. :)

  10. #10
    atom86 is offline Member
    Join Date
    Sep 2009
    Location
    Italy, Turin
    Posts
    39
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    No worries lol, he'll tryout your solution as well. I'm sure about that. :)
    now that i know this, i feel much better:)

    anyway what are you saying is true, but if in this situation the customer need to use photoshop as a default application to open images (lots of graphics do this) this solution is quicker... if not it's not a good idea as you said before.

  11. #11
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    Quote Originally Posted by atom86 View Post
    anyway what are you saying is true, but if in this situation the customer need to use photoshop as a default application to open images (lots of graphics do this) this solution is quicker... if not it's not a good idea as you said before.
    Yes your solution is okay, as I said earlier. In most of the case customer want to open only a specific image using photoshop, not all the images.

Similar Threads

  1. Replies: 4
    Last Post: 10-07-2009, 09:14 AM
  2. Opening in Java and .Net
    By techinvo in forum Jobs Offered
    Replies: 0
    Last Post: 03-22-2009, 07:24 AM
  3. Opening for java Professionals
    By careertechy in forum Jobs Offered
    Replies: 2
    Last Post: 01-15-2009, 12:40 PM
  4. [SOLVED] opening/running a program from java
    By xcallmejudasx in forum New To Java
    Replies: 3
    Last Post: 11-25-2008, 08:12 AM
  5. To open an image file such as Jpeg file using JAva Program
    By itmani2020 in forum Advanced Java
    Replies: 10
    Last Post: 07-11-2008, 09:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •