Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-13-2009, 02:55 PM
|
#1
|
LQ Newbie
Registered: Mar 2009
Posts: 3
Rep:
|
Compose two smaller images into one larger image
Hi,
I've been using python's PIL (import Image in py2.5) and the command line utility ImageMagick to add text to images and compose images.
I can't figure out how to get the composed image not to crop. That is, suppose I compose A onto B to create C. A is short and wide, while B is tall and narrow. I'd like C to be tall and wide, but instead it has the same dimensions as B.
Code:
A = [-------]
B = [x]
[x]
[x]
desired
C = [-------]
[x......]
[x......]
The width of A is determined by dynamic text. My current solution is to get the width and height of A and B, and then create a maximally sized image, T, onto which I compose B and then A.
I'm just wondering if there is some way to streamline this. Can ImageMagick do this for me? These operations take a non-trivial amount of time.
Thx.
|
|
|
03-13-2009, 07:40 PM
|
#2
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196
|
Code:
convert a.svg b.gif -append c.jpg
Of course this works for all files in the same format as well. It does exactly what you describe.
The only thing is, it is not fast. If you say that these operations take a non trivial amount of time, I assume you mean execution time.
When I appended a 1024x70 and a 700x1050 image, I estimate the time at 1-2 seconds on a 1700+ MHz AMD Duron.
The culprit seems to be identify: indentiying 1024x70 is instantaneous, identifying the 700x1050 to a noticable amount of time. I think that IM does what you did in 3 statements.
jlinkels
|
|
|
03-13-2009, 09:31 PM
|
#3
|
LQ Newbie
Registered: Mar 2009
Posts: 3
Original Poster
Rep:
|
jlinkels, thanks for the reply.
-append is not the option i'm looking for. It literally appends (or stacks) images one after the other:
Code:
A = [xx]
B = [yyy]
convert A B -append C
C = [xx.]
[yyy]
I'd like to do the equivalent of python's Image.paste, or ImageMagick's convert/compose -draw option:
Code:
A = [xx]
B = [yyy]
compose A B C
C = [xxy]
|
|
|
03-14-2009, 08:14 AM
|
#4
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,196
|
Code:
A = [xx]
B = [yyy]
convert A B -append C
C = [xx.]
[yyy]
I see. You want to put the banner on top of the narrow image, and thereby you want the large image to cause the narrow image's background to stretch so it accomodates the wide one.
What if you
1. create an image out of the wide one, but reduce it to 1 pix in height
2. append the narrow one to this one pix image, will cause to stretch the background.
3. Then paste the wide banner on top of the composite what you got
It will not be cropped (the image is widened now), and only one pixel higher than it should be.
If you are a purist, paste the wide banner with y=+1 offset, and crop the composite image to cut off the 1 pixel high helper image.
Does that make sense?
jlinkels
|
|
|
03-15-2009, 12:45 AM
|
#5
|
LQ Newbie
Registered: Mar 2009
Posts: 3
Original Poster
Rep:
|
thanks for sticking with this topic, though i have to confess that it's not a big deal. i end up with something kind of like what you suggest, only i simply create an appropriately sized image from the get go, rather than appending (your steps 1 and 2). perhaps appending is much faster?
my biggest problem is actually that photoshop compressed png's get mucked up somehow, and when i past a masked icon on top of the image it comes out noisy. it's as though white is used as the transparency color, even though that part is not supposed to be transparent. works fine on pngs created using open source image programs.
photoshop is known for ignoring image formats in favor of proprietary formats, so perhaps that's the problem. perhaps it's the compression. unfortunately, i expect users will use photoshop a bunch. i'm not sure how to test for position failure, though, so it's a sticky situation.
the final images have to be les than 800kb, so compression is likely.
you can check out the app here: http://whynoti.org
|
|
|
All times are GMT -5. The time now is 03:20 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|