• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Edit text in image using Java

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Is there a way to edit text in the image using java just like Adobe Photoshop does?

Well let me tell my requirement first.. I am working on a project in which there is a requirement for text resizing(Only width and not height). To achieve that I converted the text to image and was able to resize it. Now my query is I am unable to edit that text. I cannot save the text somewhere and use it while editing bcz there could be more than 100's of text so that would be a very bad option.

So can anyone tell me how to edit the text from the image? Is it possible in Java?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not even Photoshop can do that if the image is a JPEG/GIF/PNG/etc. file. That's only possible if the text is saved separately from the bitmap data, like in layers in Photoshop.
 
Avinash Yn
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Not even Photoshop can do that if the image is a JPEG/GIF/PNG/etc. file. That's only possible if the text is saved separately from the bitmap data, like in layers in Photoshop.



Ok. So can you please tell me how to achieve the same in Java?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't. Not unless you keep two separate image files - one with the bitmap, and one with the text (which you would regenerate every time you need to change font sizes), and then overlay those images into one.
 
Avinash Yn
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:You can't. Not unless you keep two separate image files - one with the bitmap, and one with the text (which you would regenerate every time you need to change font sizes), and then overlay those images into one.



Ok But Ulf Dittmer correct me if I am wrong, Lets say I have 2 image files now- bitmap and text. but how can I edit them as both are in the image format. I am confused. please help me out
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The file containing the text would have to have a transparent background. Then you can overlay them into a single image, as described here: http://stackoverflow.com/questions/2318020/merging-two-images
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
would showing the images as the background of a JLabel work?
then you could do whatever you wanted with the text.
 
Avinash Yn
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:The file containing the text would have to have a transparent background. Then you can overlay them into a single image, as described here: http://stackoverflow.com/questions/2318020/merging-two-images



Hi Ulf Dittmer, After you said that we need to have text and image separately, I did that and now I am able to convert the image back to text i.e. on image click I am hiding image and showing text. but there is 1 more issue i.e. if i resize the image width and height and then click the image I get the text with unresized version (As resize is done on image and not on text). So how do I increase/decrease the font size as I resize the image.

Any idea about this? I know that this is possible because it is done in photoshop, so java also should have feature.. hope it has!!
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

After you said that we need to have text and image separately, I did that and now I am able to convert the image back to text i.e. on image click I am hiding image and showing text. but there is 1 more issue i.e. if i resize the image width and height and then click the image I get the text with unresized version (As resize is done on image and not on text). So how do I increase/decrease the font size as I resize the image.



Sorry, I don't understand this. You talk of "converting an image back to text", but what I advised did no such thing (which would amount to OCR). How, exactly, are you now showing text on an image, and how do the user interactions influence what's shown? Is there a server access involved?

I know that this is possible because it is done in photoshop, so java also should have feature.


Only in the sense that Java is a programming language, so whatever Photoshop does can certainly be programmed in Java as well. Photoshop is hugely complex, though, whereas Java isn't exactly a mainstay for image processing implementations. So you may have to write the code yourself.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic