S.
Some image magic
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
	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
- Snorkasaurus
 - Berserk
 - Posts: 587
 - Joined: 30 Dec 2013, 19:19
 - Contact:
 
Re: Some image magic
Wow... that rounded corner stuff is way more complicated than it has to be.  Not that GIMP is any better, it is almost as bloated as the application it is supposed to replace.   
 
S.
			
									
									
						S.
Re: Some image magic
If you mean in Gimp - yes that is a time consuming procedure.
That is why I use Image Magic; it is way faster and can treat a lot of pics at the same time.
If you mean my descriptions you must remember that I have described several ways of creating rounded corners, and the results vary.
You can use "one command to rule them all" as I will show below:
If you put all the images you want to edit in one directory like "work" you can then provide all jpg pictures or png pictures with a soft edge and rounded corner effect by simply using *.jpg or *.png
Like this:
It will create a new set of pics (off all *.jpg pics) called soft-edge-0.png, soft-edge-1.png, soft-edge-2.png - and so on. The all will have the soft edges and a rounded corner effect - and if you don like it delete all beginning with "soft-edge", alter the parameters and have another go..
If you want to convert all your .png pics simply change *.jpg to *.png,
Before

After

If you want a softer edge you can change the parameter 0x8 to say.. 0x18 in the command above it will look like this:
 
 
But you only want rounded corners and never asked for those soft edges you say? (See? I know you
)
Try changing -level above with -threshold
 
 
It will take a few seconds to do it with 50 pics, and it would take a year to treat them one by one in Gimp.
You could make an alias of it like rcornerjpg or roundedcornerpng etc; whatever you will remember...
After that you can take the best one and give it that final touch in Gimp.
One line - one command - some adjusted parameters..... and all those fantastic results.
Even a baby can do it:

 
 
It is that easy!
			
									
									That is why I use Image Magic; it is way faster and can treat a lot of pics at the same time.
If you mean my descriptions you must remember that I have described several ways of creating rounded corners, and the results vary.
You can use "one command to rule them all" as I will show below:
If you put all the images you want to edit in one directory like "work" you can then provide all jpg pictures or png pictures with a soft edge and rounded corner effect by simply using *.jpg or *.png
Like this:
Code: Select all
convert  *.jpg -alpha set -virtual-pixel transparent -channel A -blur 0x8  -level 50%,100% +channel  soft_edge.pngIt will create a new set of pics (off all *.jpg pics) called soft-edge-0.png, soft-edge-1.png, soft-edge-2.png - and so on. The all will have the soft edges and a rounded corner effect - and if you don like it delete all beginning with "soft-edge", alter the parameters and have another go..
If you want to convert all your .png pics simply change *.jpg to *.png,
Before

After

If you want a softer edge you can change the parameter 0x8 to say.. 0x18 in the command above it will look like this:
 But you only want rounded corners and never asked for those soft edges you say? (See? I know you
)Try changing -level above with -threshold
 It will take a few seconds to do it with 50 pics, and it would take a year to treat them one by one in Gimp.
You could make an alias of it like rcornerjpg or roundedcornerpng etc; whatever you will remember...
After that you can take the best one and give it that final touch in Gimp.
One line - one command - some adjusted parameters..... and all those fantastic results.
Even a baby can do it:

It is that easy!
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!"
						"There are no stupid questions - Only stupid answers!"
- Snorkasaurus
 - Berserk
 - Posts: 587
 - Joined: 30 Dec 2013, 19:19
 - Contact:
 
Re: Some image magic
I actually meant the applications... even ImageMagick.
So when I say I don't like GIMP I mean that it is trying to be a replacement for Photoshop. Which in my mind is about as crazy as trying to be a replacement for forum spam... who needs that? GIMP is big, really big. And some of the features are very non-intuitive. I haven't done rounded corners in GIMP in a long time but if I recall correctly it was reasonably easy... but who the hell needs that much application for such a straightforward task?
When I said that even ImageMagick was over complicated I was referring to the process of creating template transparent corners, positioning them over the original image and then flattening it. However...
 
S.
			
									
									
						viking60 wrote:If you mean in Gimp - yes that is a time consuming procedure.
So when I say I don't like GIMP I mean that it is trying to be a replacement for Photoshop. Which in my mind is about as crazy as trying to be a replacement for forum spam... who needs that? GIMP is big, really big. And some of the features are very non-intuitive. I haven't done rounded corners in GIMP in a long time but if I recall correctly it was reasonably easy... but who the hell needs that much application for such a straightforward task?
When I said that even ImageMagick was over complicated I was referring to the process of creating template transparent corners, positioning them over the original image and then flattening it. However...
Now this I can work with... no transparent templates to keep handy, easy to automate with a script, and as an added bonus PNG files already have the EXIF information stripped. Dude, I am sold.viking60 wrote:But you only want rounded corners and never asked for those soft edges you say? (See? I know you)
Code: Select all
convert *.png -alpha set -virtual-pixel transparent -channel A -blur 0x8 -threshold 50%,100% +channel soft_edge.png
S.
Re: Some image magic
Yup That looks great - you have got the hang of it. Those masking techniques come in handy when making buttons etc.,  corners may not be the most practical use.



			
									
									


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!"
						"There are no stupid questions - Only stupid answers!"
Re: Some image magic
If you want to convert a picture to png (or whatever format) you can use imagemagic.
You could make a python script like this:
convert.py
After that you can simply type ./convert.py and enter the path to where your picture is and convert it to png or tiff or whatever.
The script will ask for the full path to where the pic to convert is (your working directory) /home snork/Pictures/workingdirectory
It will list the content of that directory and ask you to write in the file you want to convert (snork,jpg - which must exist there)
Then it will ask you what the out file should be (supersnork.png - which will be created)
 
 

			
									
									You could make a python script like this:
convert.py
Code: Select all
#! /usr/bin/env python
import subprocess
import os
path=input('Enter your working directory - full path to where your pics are:  ')
os.chdir(path)
from subprocess import call
call([ "ls", "-l"])
#import subprocess
pic=input ('Please enter a picture including the extension: ')
out =input ('Please enter the destination, including the extension you want to convert to: ')
params = ['convert', pic, out]
#subprocess.check_call(params)
print ('Congratulations! Everything went fine,', out , 'was created in', path)
Wait= input('PRESS ENTER TO CONTINUE')After that you can simply type ./convert.py and enter the path to where your picture is and convert it to png or tiff or whatever.
The script will ask for the full path to where the pic to convert is (your working directory) /home snork/Pictures/workingdirectory
It will list the content of that directory and ask you to write in the file you want to convert (snork,jpg - which must exist there)
Then it will ask you what the out file should be (supersnork.png - which will be created)
 
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!"
						"There are no stupid questions - Only stupid answers!"
- Snorkasaurus
 - Berserk
 - Posts: 587
 - Joined: 30 Dec 2013, 19:19
 - Contact:
 
Re: Some image magic
Actually I try to avoid interpreters like Python if I can... that is one of my disappointments with modern Linux is that they seem to be packed with those kinds of apps. 
Not to say that Microsoft hasn't just shoved .NET in to Windows.
 
S.
			
									
									
						Not to say that Microsoft hasn't just shoved .NET in to Windows.
 S.
Re: Some image magic
In that case you can simply put this bash script in your working directory:
rounded.sh
Simply enter the in file and the out file with a space between them (baby.jpg mybaby.png) and it will create mybaby.png with rounded corners (of course baby.jpg has to exist in that directory).
You get both the conversion from jpg to png and rounded corners - two for the price of one.
If you rename it to rounded and copy it to /usr/bin and chmod it:
You can convert any picture in any directory by typing rounded in a terminal and enter the pic to convert and the out file.
			
									
									rounded.sh
Code: Select all
#!/bin/bash
 echo 'Please enter a picture including the extension and the desired out file: '
read PIC OUT
 string="convert  ${PIC} -alpha set -virtual-pixel transparent -channel A -blur 0x8  -threshold 50%,100% +channel  ${OUT}"
$string
Simply enter the in file and the out file with a space between them (baby.jpg mybaby.png) and it will create mybaby.png with rounded corners (of course baby.jpg has to exist in that directory).
You get both the conversion from jpg to png and rounded corners - two for the price of one.
If you rename it to rounded and copy it to /usr/bin and chmod it:
Code: Select all
sudo chmod +x /usr/bin/roundedYou can convert any picture in any directory by typing rounded in a terminal and enter the pic to convert and the out file.
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!"
						"There are no stupid questions - Only stupid answers!"
Re: Some image magic
Ok I realize that this has become a long thread and can be somewhat complicated so I gathered a few of the functions described here in a script.
 
 
The best way to use it is to put it in your /usr/local/bin
and chmod it to execute
I have called the script berserkimg but you may call it whatever you want.
After you have done that you can simply type berserkimg in a terminal:

You can create pics with rounded corners, flip a pic in whatever angel you care to enter (90 and 180 would be the most common ones but you may enter 45 or whatever) or convert pdf to png nicely structured per page.
Wildcards are accepted. So this thing is actually useful.
If you want to flip the current baby picture 90 degrees you would enter something like this:
simply enter the parameters with a space in-between them.
In the case of rounded corners and flip pictures the result will be shown to you and the script will continue once you close it.
Video coming up....
 
 
Edit: added some new functions to the menu
			
									
									
 The best way to use it is to put it in your /usr/local/bin
and chmod it to execute
Code: Select all
sudo chmod +x /usr/local/bin/berserkimgI have called the script berserkimg but you may call it whatever you want.
After you have done that you can simply type berserkimg in a terminal:

You can create pics with rounded corners, flip a pic in whatever angel you care to enter (90 and 180 would be the most common ones but you may enter 45 or whatever) or convert pdf to png nicely structured per page.
Wildcards are accepted. So this thing is actually useful.
If you want to flip the current baby picture 90 degrees you would enter something like this:
Code: Select all
baby.jpg 90 test.pngsimply enter the parameters with a space in-between them.
In the case of rounded corners and flip pictures the result will be shown to you and the script will continue once you close it.
Video coming up....
 Edit: added some new functions to the menu
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!"
						"There are no stupid questions - Only stupid answers!"



