Some image magic

Every day solutions to every day challenges. + Brilliant stuff

Moderators: b1o, jkerr82508

Forum rules
Please feel free to post your tip it does not have to be advanced. Also ask questions directly related to the tip here. But do not start new threads with questions or ask for help here. That is what the help section is for. forum rules: http://bjoernvold.com/forum/viewtopic.php?f=8&t=568
User avatar
rolf
Guru-Berserk
Posts: 1107
Joined: 16 Mar 2010, 16:07

Re: Some image magic

Postby rolf » 19 Mar 2013, 14:08

Now I am officially framed....

That reminds me...

Code: Select all

convert -border 7x7 -bordercolor red vikingt1.png vikingframed.png
:A
ImageImage

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Some image magic

Postby viking60 » 19 Mar 2013, 14:20

:lolup Yup you do not get more framed than that :lol: And we learned how to put a colored frame around it too :B
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Some pdf magic

Postby viking60 » 20 Mar 2013, 12:16

You often get those pdf's from companies with fantastic pictures that you would love to use right (BMW, Mercedes etc)? And since they are delivered in pdf format you cannot use the pics :-x
Well there is a solution:
Normally one would think that

Code: Select all

convert foo.pdf pages.png
Would do the trick - but no. It breaks up the pdf in different sections but the naming gets wrong: Like this pages.png.2 pages.png.3 pages.png.4
So this will do it:

Code: Select all

convert foo.pdf pages-%03d.png

The %03d is a printf-style format specifier and now the pdf is broken down like this:
pages-000.png pages-001.png pages-002.png pages-003.png

Now you can grab the pictures and edit in Gimp or whatever.
Of course you need to get the permission from the copyright holders in order to use the pics - but you knew that - right?
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Rounded corners

Postby viking60 » 21 Mar 2013, 03:25

I decided to create some transparent corners and add them to a pic. And I found out that the NorthWest and SouthEast thing is very presize.
I created four corners called nw ne sw and se.png
Well I actually created one and rotated it a couple of times :-D
Then I picked a random picture and added the corners to it like this:

Code: Select all

composite -gravity NorthEast ne.png output.png guru.png
and

Code: Select all

composite -gravity NorthWest nw.png guru.png guru-1.png

By now the image looks like this (guru-1.png):
Image
then

Code: Select all

composite -gravity SouthWest sw.png guru-1.png guru-2.png
and

Code: Select all

composite -gravity SouthEast se.png guru-2.png guru-3.png

:A
Image

Here are the corners i used
->Image->Image
->Image
->Image
You cannot see them because they are transparent., but you can download them and use them (actually you can barely see them because i did not make them perfect so you can see the white background -to make it perfectly integrated here that background should have been light blue)
Here I have reduced the size of the corners above to 50% with:

Code: Select all

mogrify -resize 50% se.png sw.png nw.png ne.png

Image
Image

Here is an image where the cornes have the background of this forum (you can see the white bg on the other images) so it is perfectly integrated:
Image
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

rounded corner magic

Postby viking60 » 21 Mar 2013, 13:43

I probably lost most of you with that complicated rounded corner stuff above -right? And it is probably easier done in Gimp anyway.

What you want is the simple command that you can copy and paste and make it happen +1
So here we go:

Code: Select all

convert party.jpg -alpha set -virtual-pixel transparent -channel A -blur 0x8  -level 50%,100% +channel  soft_edge.png

Image
You can also use the threshold switch:
:A

Code: Select all

convert party.jpg -alpha set -virtual-pixel transparent -channel A -blur 0x8  -threshold 50%,100% +channel  party.png

Image

The only thing you need to change here is party.jpg (unless you have a pic called that).
It is not as slick as the above but it is fast. And you can do it to the entire directory with one comand:

Code: Select all

convert *.jpg -alpha set -virtual-pixel transparent -channel A -blur 0x8  -level 50%,100% +channel  soft_edge.png

Will round all your jpg images.
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Some image magic

Postby viking60 » 21 Mar 2013, 14:40

If you want that Old "from the Wild West/Silent movie" portrait look you can do this:

Code: Select all

convert party.jpg -alpha set -background none -vignette 0x4 pblur.png


ImageImage
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
rolf
Guru-Berserk
Posts: 1107
Joined: 16 Mar 2010, 16:07

Re: Some image magic

Postby rolf » 21 Mar 2013, 14:56

:B Good tips. We're witnessing the next Instagram, in the making. :berserkf

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Some image magic

Postby viking60 » 21 Mar 2013, 17:58

Instagram is a stalkers wet dream so that is not likely :-D
Anyway here is a command that creates and draws up the corners and places them on the image.
As the gurus know - and you might not - the "\" will allow you to write the command over several lines with a ">" prompt in your terminal. When finished just hit Enter and the command executes.
My pic is called good.png yours will be different. It will give you a new pic called rounded_corners.png

Code: Select all

 convert good.png \
     \( +clone  -alpha extract \
        -draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
        \( +clone -flip \) -compose Multiply -composite \
        \( +clone -flop \) -compose Multiply -composite \
     \) -alpha off -compose CopyOpacity -composite  rounded_corners.png

Here the effect is perfect.
Image
All you have to do is to change good.png in the code above and run the code in a terminal in the directory where your pic is. (edit it before you paste it).
I am on a roll now so I had to put a shadow on it:

Code: Select all

convert -page +4+4 rounded_corners.png -alpha set           \( +clone -background navy -shadow 60x4+4+4 \) +swap           -background none -mosaic     shadow_soft.png

Image
It is all on the imagemagick website. IBM also has some nice tips for imagemagic. And I often have more trouble using GUI's than the CLI for image manipulation. It depends on what you want to do. Imagemagic is Great stuff!
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Some image magic

Postby viking60 » 23 Mar 2013, 16:08

Here I have put Gizmo (gizmo2.png) in a glass buble.
Image
I used this image as a mask (badge_overlay140.png)
Image
And then I entered this command:

Code: Select all

convert gizmo2.png  -gravity center -extent 140x140  badge_overlay140.png -composite badge.png
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
rolf
Guru-Berserk
Posts: 1107
Joined: 16 Mar 2010, 16:07

Re: Some image magic

Postby rolf » 23 Mar 2013, 20:06

:B Very sophisticated. Is Gizmo running for Mayor of Fyllingsdalen and that's his campaign button? :think:

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Some image magic

Postby viking60 » 24 Mar 2013, 10:28

Yup he is a confident guy with lots of ambitions.
So he has appointed you his campaign general - since he will now gracefully accept the task of improving your presidency.
Here is the badge that you can distribute.
Image
According to Gizmo Obama is toast now.
He is annoyed that he only will be the second black president though...
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"

User avatar
viking60
Über-Berserk
Posts: 9351
Joined: 14 Mar 2010, 16:34

Re: Some image magic

Postby viking60 » 25 Jun 2014, 14:09

Imagemagic can be used to take snapshots of your desktop too.
The import command takes care of that.
You can take a snapshot like this

Code: Select all

import test.png

..and click on the window you want to take a snapshot of or click on the desktop for a snapshot of all.

You can take multiple snaps in one operation.
This command will wait for you to click on three windows and then take a snap of all of them:

Code: Select all

import  -snaps 3 berserksnap.jpeg

:A
Image
Manjaro 64bit on the main box -Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz and nVidia Corporation GT200b [GeForce GTX 275] (rev a1. + Centos on the server - Arch on the laptop.
"There are no stupid questions - Only stupid answers!"


Return to “Tips & Tricks”