Fedora Linux Support Community & Resources Center
  #1  
Old 12th March 2017, 11:22 PM
User808 Offline
Registered User
 
Join Date: Aug 2016
Location: Iraq
Posts: 688
linuxfedorafirefox
Help me with variables !

Hi.

Please look for this command:

$ convert *.tiff -deskew 80% -morphology Close Diamond:1 -sharpen 0x10 -alpha off -monochrome -compress Group4 output.pdf

I like to convert it to script called "optimize-to-pdf.sh"

Quote:
#! /bin/bash
convert *.tiff -deskew 80% -morphology Close Diamond:1 -sharpen 0x10 -alpha off -monochrome -compress Group4 output.pdf
I like to make a variable for *.tiff so that I can select image format type to be processed. Also, if possible, to make variable for "output.pdf" so that can I select name of output PDF.
__________________
Fedora 26 X64 bit Cinnamon edition on Lenovo ThinkPad e550 with Intel core i7 5500 CPU @ 2.40 GH X 2, RAM = 8 GB, HHD = 1 TB, Hybrid VGA (Intel Corporation HD Graphic 5500 + Radeon R7 M265 2GB)
Reply With Quote
  #2  
Old 13th March 2017, 04:27 AM
hiGuys Offline
Registered User
 
Join Date: Jun 2013
Location: USA
Posts: 362
linuxfirefox
Re: Help me with variables !

You could experiment with $1 and $2.

Code:
#! /bin/bash
convert *."$1" -deskew 80% -morphology Close Diamond:1 -sharpen 0x10 -alpha off -monochrome -compress Group4 "$2"
Code:
$ optimize-to-pdf.sh png custom_output.pdf
I didn't test this, so there might be syntax errors to be dealt with, but the general idea in bash is that $1 will be replaced with the first argument of the command and $2 with the second.
__________________
Mind the gap.

Last edited by hiGuys; 13th March 2017 at 05:56 AM.
Reply With Quote
  #3  
Old 13th March 2017, 11:05 PM
User808 Offline
Registered User
 
Join Date: Aug 2016
Location: Iraq
Posts: 688
linuxfedorafirefox
Re: Help me with variables !

@hiGuys

Thank you very much ! It work ! But I modify what you suggest as following:

Quote:
#! /bin/bash
convert *."$1" -deskew 80% -morphology Close Diamond:1 -alpha off -monochrome -compress Group4 "$2".pdf
1) Look for what I marked by red. This command specifically written to convert into PDF not other format. It is unwise to allow for chosen other format output because, for ex: compression option will not be suitable for other output format.

2) I discovered, by experience that "-sharpen 0x10" or even "-sharpen 0x1.0" tend to reverse function of "-morphology Close Diamond:1". So, it is better not to use "-sharpen" at all.

----------------------------

Please beware: this command (script) should to applied ONLY ON ALREADY MONOCHROME (BLACK & WHITE) IMAGES. If you have colored image you should convert them 1st to monochrome images before process them by this command (script) ........ .
__________________
Fedora 26 X64 bit Cinnamon edition on Lenovo ThinkPad e550 with Intel core i7 5500 CPU @ 2.40 GH X 2, RAM = 8 GB, HHD = 1 TB, Hybrid VGA (Intel Corporation HD Graphic 5500 + Radeon R7 M265 2GB)
Reply With Quote
  #4  
Old 13th March 2017, 11:23 PM
hiGuys Offline
Registered User
 
Join Date: Jun 2013
Location: USA
Posts: 362
linuxfirefox
Re: Help me with variables !

Very glad it worked out for you. Sounds like you are making good progress on your project. Yes, if you will only have pdf files for output it makes very good sense to code it like you have.
__________________
Mind the gap.
Reply With Quote
Reply

Tags
variables

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I can't keep variables on env sputnik99 Using Fedora 6 4th March 2014 04:15 AM
how to set environment variables? Seedrick Using Fedora 3 23rd May 2010 01:47 PM
Using variables in yum pingoomax Using Fedora 1 23rd February 2007 06:47 PM
environment variables? hari_mj23 Using Fedora 9 3rd April 2006 07:03 AM
Environment variables Flatron Using Fedora 7 28th January 2006 03:47 AM


Current GMT-time: 21:05 (Sunday, 24-09-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat