Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 19 Nov 2017, 12:35
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
mtPaint - Simple paint tutorial
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 5 of 7 [94 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Author Message
dejan555


Joined: 30 Nov 2008
Posts: 2797
Location: Montenegro

PostPosted: Tue 28 Oct 2014, 04:15    Post subject:  

don570 wrote:

Code:

#!/bin/sh
 for ZAD in /root/my_images/*.jpg ;do
  SUFFIX=_mod
  mtpaint --cmd -file/open="$ZAD" -e/'Load Clipboard'/1 -e/paste x=0 y=0   -selection/'Select None' -file/as="$ZAD"$SUFFIX
  mv -f  "$ZAD"$SUFFIX.jpg   "${ZAD%.jpg}"$SUFFIX.jpg
done



I think suffix replacement could be done nicer and without mv:

Code:
#!/bin/sh
 for ZAD in /root/my_images/*.jpg ;do
  SZAD=${ZAD/%.jpg/_mod.jpg}
  mtpaint --cmd -file/open="$ZAD" -e/'Load Clipboard'/1 -e/paste x=0 y=0   -selection/'Select None' -file/as="$SZAD"
done

_________________
puppy.b0x.me stuff mirrored HERE
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
wjaguar

Joined: 21 Jun 2006
Posts: 335

PostPosted: Tue 28 Oct 2014, 04:39    Post subject:  

dejan555 wrote:
SZAD=${ZAD/%.jpg/_mod.jpg}

This is a bashism, not portable to other shells.
To do the same in a standard way:
SZAD="${ZAD%.jpg}_mod.jpg"
Back to top
View user's profile Send private message 
dejan555


Joined: 30 Nov 2008
Posts: 2797
Location: Montenegro

PostPosted: Tue 28 Oct 2014, 08:00    Post subject:  

Hmm, yeah I've been reading more on using bash variable manipulations so I can use the builtins instead calling external programs when possible.
If anyone knows a good tutorial on this using standard "sh" (posix?) language link me.
And is there really a standard way that is applicable to all shells?
I know most of them have a switch to emulate standard shell or if called through #!/bin/sh symlink
Googling mostly gives results based on bash specifically.

_________________
puppy.b0x.me stuff mirrored HERE
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
wjaguar

Joined: 21 Jun 2006
Posts: 335

PostPosted: Tue 28 Oct 2014, 12:34    Post subject:  

dejan555 wrote:
And is there really a standard way that is applicable to all shells?

Yes. It is what POSIX standard is for. The Open Group Base Specifications, Chapter 2 - Shell Command Language
Quote:
I know most of them have a switch to emulate standard shell or if called through #!/bin/sh symlink

Bash's "POSIX mode" does a lot of tweaks, but does NOT disable its syntax extensions.
Quote:
Googling mostly gives results based on bash specifically.

It also gives lists of things not to do, if script is to work on Debian/Ubuntu's dash. Like this one, and another linked from it.
Back to top
View user's profile Send private message 
dejan555


Joined: 30 Nov 2008
Posts: 2797
Location: Montenegro

PostPosted: Tue 28 Oct 2014, 12:59    Post subject:  

Thanks, seems like they're all usefull links, however on the Bashism link where there's example similar to what I proposed says that this kind of parameter expansion is not defined by posix and offers alternative of calling printf/sed

Quote:
${name/foo/bar} -- you can use $(printf '%s\n' "$name" | sed 's/foo/bar/'), after changing shell patterns to regular expressions. This originated in ksh93 and is also present in mksh, and zsh, but ksh93's substitution expansion differs from Bash's.

_________________
puppy.b0x.me stuff mirrored HERE
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
wjaguar

Joined: 21 Jun 2006
Posts: 335

PostPosted: Tue 28 Oct 2014, 14:55    Post subject:  

dejan555 wrote:
on the Bashism link where there's example similar to what I proposed says that this kind of parameter expansion is not defined by posix and offers alternative of calling printf/sed

Yes but that is for the generic case, when you need to do an undefined number of replacements, and/or need to match a complicated regex patten. Which in practice is quite rare.

The real, practicable cases are easily done through pattern remove.
When you know that the substring you want replaced is at end of string, you remove a suffix and add the replacement:
"${SOURCE%substring}replacement"
When you know it's at the beginning - the same, but remove a prefix:
"replacement${SOURCE#substring}"
And when you only know it's in there somewhere - you split the string in two on it, and merge back around the replacement:
"${SOURCE%%substring*}replacement${SOURCE#*substring}"

Even in replacing multiple substrings, you can avoid firing up sed, by doing the "middle replacement" above in a while loop - with the condition being that string after pattern remove is not the same as before:
while [ "$STRING" != "${STRING%substring*}" ]
Same condition in an if is used to check for presence of pattern in string.

You can find many usage examples of all these in the scripts in mtPaint package. Smile
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Tue 28 Oct 2014, 19:49    Post subject:  

wjaguar wrote:
You can find many usage examples of all these in the scripts in mtPaint package.


I didn't know there were scripts available Embarassed
When you compile shouldn't you create a /usr/share/doc/ folder and
put the scripts in there?

________________________________________________________
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Tue 28 Oct 2014, 20:06    Post subject:  

A corporate logo

A corporate logo should be saved to your hard disk, not in a clipboard
so I have revised the logo tutorial to use the alpha channel instead.
This is much better. Cool

Goal : to make a company logo

1) make a screenshot of interesting face.

2) make rectangle beside the face in the color of desired text



3) The next step is to make some region alpha=1 i.e. make that region visible

Channels > Edit Alpha
Channels > View Alpha as an overlay

4) Magnify to 300%
Use brush to select the logo.
Don't paint outside of logo .
(The alpha=0 region has a blue tint. alpha=1 region is non-tinted)

5) Gaussian blur of 2 --> this give slight blurring to edge of face

6) Place text in rectangle (invert must be ticked)



7) Channels > Edit Image

8 ) Selection > Select All

9) Paste in original document. (Press <ENTER> key to place permanently)

10) Save to PNG file (leave default settings since these will preserve transparency)

11) Check with Viewnior image viewer (or equivalent) to see results.


Now logo and text can be used in another document
using a simple copy to clipboard and paste(see image for final result)


Last edited by don570 on Thu 15 Jan 2015, 20:02; edited 2 times in total
Back to top
View user's profile Send private message 
wjaguar

Joined: 21 Jun 2006
Posts: 335

PostPosted: Tue 28 Oct 2014, 20:09    Post subject:  

don570 wrote:
I didn't know there were scripts available Embarassed
When you compile shouldn't you create a /usr/share/doc/ folder and
put the scripts in there?

No, I meant the buildscripts in the source package: ./configure and gtk/winbuild.sh
These are rather heavy on string operations, and by necessity portable.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Thu 28 Jan 2016, 21:35    Post subject:  

Here's the quick way to restrict an effect to a smaller area of the image
using mtpaint. It requires that you copy the smaller area to an upper layer...

Here is example of making part of image greyscale . the rest of image is
unchanged.

select area ---> polygon tool , drag of mouse
Edit > Copy
Edit > Paste to New Layer
Tick ---> Show all layers in main window
Press ESC to eliminate the dashed lines
(Note that these dashed lines refer back to lower layer
and still could be useful for an outline command for example)

Now do an effect on the new layer such as ...

Effects > Greyscale
Effects > Transform hue
Effects > Gausssian blur

You can save your result two ways. Look under 'Layers' menu

1) Save all layers (using File menu) and then use the command to save as composite
Layer > Save composite image


2) Make a composite layer and save this composite layer
Layer > "Composite to New Layer"
________________________________________________
screenshot-mtpaint-second.jpg
 Description   process of making part of image greyscale
 Filesize   21.98 KB
 Viewed   430 Time(s)

screenshot-mtpaint-second.jpg


Last edited by don570 on Wed 03 Feb 2016, 21:05; edited 4 times in total
Back to top
View user's profile Send private message 
wjaguar

Joined: 21 Jun 2006
Posts: 335

PostPosted: Fri 29 Jan 2016, 06:10    Post subject:  

don570 wrote:
Here's the quick way to restrict an effect to a smaller area of the image using mtpaint. It requires that you copy the smaller area to an upper layer...

The regular way to restrict any drawing op, effects included, to an area, is to mask the rest of image using mask channel.
http://mtpaint.sourceforge.net/handbook/en_GB/chap_07.html#SEC3
- select area
- Channels->New: Mask, Cleared
- Channels->Edit mask
- Selection->Fill selection
- Effects->Invert
- Channels->Edit image
- do whatever
- Channels->Delete: Mask
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Sat 30 Jan 2016, 14:02    Post subject:  

Quote:
The regular way to restrict any drawing op, effects included, to an area, is to mask the rest of image using mask channel.


That may be the regular way but I like the concept of individual layers
and each layer can be manipulated. Then mtpaint is a faster and simpler
version of gimp.

___________________________________________
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Tue 08 Mar 2016, 19:57    Post subject:  

I looked at the chart making script that Dmitri has updated.
It's easy run in terminal ---> Open the folder and 'cd' inside it.

You must have mtpaint version 3.44.99 or more recent installed.
Then run script ....
/usr/bin/perl mdtim.pl

mdtim.pl ---> It's found in mtpaint handbook download in src folder
https://github.com/wjaguar/mtpaint_handbook/blob/master/src/mdtim.pl

I made four changes

1) need to find a suitable font --->"Nimbus sans L"
Raspberry pi worked with "FreeMono"
2) horizontal lines made light grey
3) Text needed correction from grey to black
4) Icons changed for a distinct shape - more professional!!

Code:

line 23

$font = "Nimbus sans L";

line 97

   $sc .= "-e/col a=9   -e/tool line " . list($main_co[0] - 6, $j, $main_co[2], $j);


line 99

   $sc .= "-e/col a=0 -e/freetype t=$i ";


An interesting thing I noticed in the script --->

'undo=1' is needed to return the chart after opening icon image.
-e/undo will then work.

You will get a warning message that undo is disabled if you don't use 'undo=1'
and the script doesn't work
mdtim.png
 Description   chart created by mdtim.pl script
 Filesize   60.51 KB
 Viewed   239 Time(s)

mdtim.png

mtpaint-chart.tar.gz
Description  perl script and icons
gz

 Download 
Filename  mtpaint-chart.tar.gz 
Filesize  4.17 KB 
Downloaded  79 Time(s) 

Last edited by don570 on Mon 13 Feb 2017, 20:40; edited 5 times in total
Back to top
View user's profile Send private message 
wjaguar

Joined: 21 Jun 2006
Posts: 335

PostPosted: Wed 09 Mar 2016, 06:09    Post subject:  

don570 wrote:
You will get a warning message that undo is disabled if you don't use 'undo=1'
and the script doesn't work

As you can guess, I never run mtPaint with that option disabled, since the day I added it. Smile
And now I think I should just set the toggle on by default in the next version. The legacy non-undoable behaviour is plain useless.
Back to top
View user's profile Send private message 
don570


Joined: 10 Mar 2010
Posts: 4755
Location: Ontario

PostPosted: Thu 10 Mar 2016, 14:51    Post subject:  

Here are two scripts to practise scaling and pasting.

Some notes:

The first part of script simply creates an SVG image in /tmp.
Then comes the command to create a PNG image.
The first script makes a document , establishes a gradient, then makes
an interesting mirrored gradient (with the cut command)
Then opens the svg image and copies it to the clipboard.

-e/undo returns the gradient
A paste is done and two yellow lines added on top
Note that gradient had to be turned off to create yellow (grad=0)

Code:

mtpaint --cmd   -f/new w=150 h=150 =24 -e/set  grad=1 -e/col a=0 b=115 -e/tool grad \(0,0 100,100\) -e/tool grad: type=lin ext=mirror -s/all -e/cut   -f/open='/tmp/tmp.svg' undo=1 -s/all -e/copy -e/undo -e/paste -e/set grad=0  size=3  -e/col a=3 -e/tool line \(0,0 150,150\) -e/tool line \(150,0 0,150\)    -f/as=/tmp/temp.png


_____________________________________________________

For the second script. A scaling of width and height is done as well

-image/scale w=x0.5 h=x1.2

Note that two undo's are needed to return the gradient because two operations were performed
-e/undo -e/undo

Code:

mtpaint --cmd   -f/new w=150 h=150 =24 -e/set  grad=1 -e/col a=0 b=115 -e/tool grad \(0,0 100,100\) -e/tool grad: type=lin ext=mirror -s/all -e/cut   -f/open='/tmp/tmp.svg' undo=1  -image/scale w=x0.5 h=x1.2   -s/all -e/copy -e/undo -e/undo -e/paste -e/set grad=0  size=3  -e/col a=3 -e/tool line \(0,0 150,150\) -e/tool line \(150,0 0,150\)    -f/as=/tmp/temp.png



mtpaint-scripts-scale.tar.gz
Description  two scripts to practice scaling
gz

 Download 
Filename  mtpaint-scripts-scale.tar.gz 
Filesize  15.69 KB 
Downloaded  89 Time(s) 
temp2.png
 Description   
 Filesize   7.96 KB
 Viewed   175 Time(s)

temp2.png

temp.png
 Description   Open and scale of svg image
 Filesize   7.75 KB
 Viewed   186 Time(s)

temp.png

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 5 of 7 [94 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0830s ][ Queries: 12 (0.0094s) ][ GZIP on ]