Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8824953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:45:33+00:00 2026-06-14T06:45:33+00:00

I’d like ask a question about image processing in Java. What I’m looking to

  • 0

I’d like ask a question about image processing in Java.

What I’m looking to achieve is to put a text below an existing image. Not over the existing image, but to append to image bottom. I have googled for that, but all the answers were the suggestions how to do the latter – how to put text on image.

Below is the example picture what result I wish to have. The original picture is the Leena image and the result by image processing is together with below the red dotted lines.

desired result

What could be fastest way to achieve this – write some text below image and also append another smaller picture?

What I thought about doing is that I append to my exisitng BufferedImage bottom 30 pixels height of white background and then write to that place a text and add a logo. Could this be most efficient approach? Are there some libs that would do that work for me or is there better approach than i mentioned?

EDIT: For better clarity I want the result as a single picture

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:45:34+00:00Added an answer on June 14, 2026 at 6:45 am

    I would take some time to have a read through

    • Performing Custom Painting
    • 2D Graphics
    • Working with Images

    This is a really basic example. I’ve not bothered with adding the code to actually render a logo, you can read through the suggested reading list and should be able to figure out how that would be achieved 😉

    enter image description here

    public class AppendImage {
    
        public static void main(String[] args) {
            new AppendImage();
        }
    
        public AppendImage() {
            EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                    } catch (ClassNotFoundException ex) {
                    } catch (InstantiationException ex) {
                    } catch (IllegalAccessException ex) {
                    } catch (UnsupportedLookAndFeelException ex) {
                    }
    
                    JFrame frame = new JFrame();
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    frame.setLayout(new BorderLayout());
                    frame.add(new ImagePane());
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
                }
            });
        }
    
        public class ImagePane extends JPanel {
    
            private BufferedImage sourceImage;
            private BufferedImage labeledImage;
    
            public ImagePane() {
    
                try {
                    sourceImage = ImageIO.read(getClass().getResource("/source.jpg"));
                    labeledImage = addLabel("Hello", sourceImage);
                } catch (IOException exp) {
                    exp.printStackTrace();
                }
    
            }
    
            @Override
            public Dimension getPreferredSize() {
                int width = sourceImage.getWidth() + labeledImage.getWidth();
                int height = labeledImage.getHeight();
    
                return new Dimension(width, height);
            }
    
            protected BufferedImage addLabel(String label, BufferedImage sourceImage) {
    
                Font font = UIManager.getFont("Label.font");
                FontMetrics fm = getFontMetrics(font);
                int width = sourceImage.getWidth() + 2;
                int height = sourceImage.getHeight() + 4 + fm.getHeight() + 4;
    
                BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                Graphics2D g2d = image.createGraphics();
                g2d.setColor(Color.WHITE);
                g2d.fillRect(0, 0, width, height);
                g2d.setColor(Color.BLACK);
                g2d.setStroke(new BasicStroke(2, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
                g2d.drawRect(0, 0, width - 1, height - 1);
                g2d.drawImage(sourceImage, 1, 1, this);
                g2d.setColor(Color.RED);
                g2d.setStroke(new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10f, new float[]{10f}, 0f));
                g2d.drawLine(0, sourceImage.getHeight() + 2, image.getWidth(), sourceImage.getHeight() + 2);
    
                int y = sourceImage.getHeight() + (((image.getHeight() - sourceImage.getHeight()) - fm.getHeight()) / 2) + 2;
                g2d.drawString(label, 2, y + fm.getAscent());
    
                String logo = "Logo here";
                int x = image.getWidth() - fm.stringWidth(logo) - 12;
                g2d.drawString(logo, x, y + fm.getAscent());
    
                g2d.dispose();
    
                return image;
    
            }
    
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                int x = 0;
                g.drawImage(sourceImage, x, 0, this);
                x += sourceImage.getWidth();
                g.drawImage(labeledImage, x, 0, this);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I have two tables with like below codes: Table: Accounts id | username |
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.