Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91570 > unrolled thread

Using Python instead of Bash

Started byCecil Westerhof <Cecil@decebal.nl>
First post2015-05-31 14:42 +0200
Last post2015-06-01 14:51 +0000
Articles 4 on this page of 24 — 11 participants

Back to article view | Back to comp.lang.python


Contents

  Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 14:42 +0200
    Re: Using Python instead of Bash Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2015-05-31 16:02 +0200
      Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 18:36 +0200
    Re: Using Python instead of Bash Cem Karan <cfkaran2@gmail.com> - 2015-05-31 10:14 -0400
      Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 18:58 +0200
    Re: Using Python instead of Bash Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-05-31 11:05 -0400
      Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-05-31 19:06 +0200
        Re: Using Python instead of Bash Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2015-05-31 20:53 -0400
          Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 11:25 +0200
        Re: Using Python instead of Bash Laura Creighton <lac@openend.se> - 2015-06-01 09:11 +0200
    Re: Using Python instead of Bash Ethan Furman <ethan@stoneleaf.us> - 2015-05-31 22:08 -0700
    Re: Using Python instead of Bash Larry Hudson <orgnut@yahoo.com> - 2015-06-01 00:56 -0700
      Re: Using Python instead of Bash Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-06-01 11:06 +0300
        Re: Using Python instead of Bash alister <alister.nospam.ware@ntlworld.com> - 2015-06-01 09:07 +0000
          Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 12:44 +0200
            Re: Using Python instead of Bash Laura Creighton <lac@openend.se> - 2015-06-01 17:44 +0200
              Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 18:44 +0200
                Re: Using Python instead of Bash Laura Creighton <lac@openend.se> - 2015-06-01 20:42 +0200
                  Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 21:57 +0200
                    Re: Using Python instead of Bash Laura Creighton <lac@openend.se> - 2015-06-01 22:42 +0200
                      Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 23:04 +0200
      Re: Using Python instead of Bash Cecil Westerhof <Cecil@decebal.nl> - 2015-06-01 11:11 +0200
        Re: Using Python instead of Bash Marko Rauhamaa <marko@pacujo.net> - 2015-06-01 12:38 +0300
    Re: Using Python instead of Bash Grant Edwards <invalid@invalid.invalid> - 2015-06-01 14:51 +0000

Page 2 of 2 — ← Prev page 1 [2]


#91724

FromCecil Westerhof <Cecil@decebal.nl>
Date2015-06-01 23:04 +0200
Message-ID<87a8wjjg37.fsf@Equus.decebal.nl>
In reply to#91713
Op Monday 1 Jun 2015 22:42 CEST schreef Laura Creighton:

> In a message of Mon, 01 Jun 2015 21:57:05 +0200, Cecil Westerhof
> writes:
>>> Truly? That's (very close to) 7 inch by 9 inch, 177.8 mm x 228.6
>>> mm and 7 by 9 is what pre-metric Britian called 'Small Post
>>> Quarto'. I wonder if this merely a coincidence, or does some
>>> software really still like this size? How very weird.
>>
>> Well, it is possible I did not measure correctly. ;-) It is a 32
>> page booklet.
>>
>> -- 
>> Cecil Westerhof
>> Senior Software Engineer
>> LinkedIn: http://www.linkedin.com/in/cecilwesterhof
>
> Ah, I have been misunderstanding the question. It's the booklet
> itself that is 7 by 9, not the rasters (or whatever) you get when
> you first scan the thing. Sorry about that.

No problem.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

[toc] | [prev] | [next] | [standalone]


#91638

FromCecil Westerhof <Cecil@decebal.nl>
Date2015-06-01 11:11 +0200
Message-ID<87r3pvlrnk.fsf@Equus.decebal.nl>
In reply to#91630
Op Monday 1 Jun 2015 09:56 CEST schreef Larry Hudson:

> On 05/31/2015 05:42 AM, Cecil Westerhof wrote:
>> I help someone that has problems reading. For this I take photo's
>> of text, use convert from ImageMagick to make a good contrast
>> (original paper is grey) and use lpr to print it a little bigger.
>>
> I''m wondering why you bother to take a photo, which then has to be
> adjusted for quality.  A screen-capture program is much easier and
> immediately gives you a perfect(?) starting image.

I am amazed about the technical progress: I did not know it was
possible to take a screen-shot from a booklet.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

[toc] | [prev] | [next] | [standalone]


#91640

FromMarko Rauhamaa <marko@pacujo.net>
Date2015-06-01 12:38 +0300
Message-ID<878uc3ahuf.fsf@elektro.pacujo.net>
In reply to#91638
Cecil Westerhof <Cecil@decebal.nl>:

> I am amazed about the technical progress: I did not know it was
> possible to take a screen-shot from a booklet.

Well, take a look at this video that demonstrates the possibilities of
the technology:

   https://www.youtube.com/watch?v=MOXQo7nURs0


Marko

[toc] | [prev] | [next] | [standalone]


#91677

FromGrant Edwards <invalid@invalid.invalid>
Date2015-06-01 14:51 +0000
Message-ID<mkhrhu$9d5$1@reader1.panix.com>
In reply to#91570
On 2015-05-31, Cecil Westerhof <Cecil@decebal.nl> wrote:

> I help someone that has problems reading. For this I take photo's of
> text, use convert from ImageMagick to make a good contrast (original
> paper is grey) and use lpr to print it a little bigger.
>
> Normally I would implement this in Bash, but I thought it a good idea
> to implement it in Python.

Why?  Is it difficult to do/maintain in Bash?

If you want to write Python, then you should write Python.  You're
still writing Bash, so you should probably do it in Bash.  If you just
want to invoke a set of external programs on a set of files, then Bash
is probably the right language to use: that's pretty much what Bash is
for: manipulating files by invoking other programs.

> This is my first try:
>     import glob
>     import subprocess
>
>     treshold = 66
>     count = 0
>     for input in sorted(glob.glob('*.JPG')):
>         count += 1
>         output = '{0:02d}.png'.format(count)
>         print('Going to convert {0} to {1}'.format(input, output))
>         p = subprocess.Popen(['convert', '-threshold', '{0}%'.format(treshold), input, output])
>         p.wait()
>         print('Going to print {0}'.format(output))
>         p = subprocess.Popen(['lpr', '-o', 'fit-to-page', '-o', 'media=A4', output])
>         p.wait()
>
> There have to be some improvements: display before printing,
> possibility to change threshold, … But is this a good start, or
> should I do it differently?

If all the work is being done by making a series of calls to 
subprocess, then you should think about using bash instead.

If you really do want to do this in Python, you can use a Python
binding to the ImageMagick libraries:

  https://wiki.python.org/moin/ImageMagick
  http://www.imagemagick.org/download/python/
  http://stackoverflow.com/questions/7895278/can-i-access-imagemagick-api-with-python

Or maybe you can use Pillow:

  http://pillow.readthedocs.org/
  https://github.com/python-pillow/Pillow  
  https://python-pillow.github.io/
  
-- 
Grant Edwards               grant.b.edwards        Yow! Of course, you
                                  at               UNDERSTAND about the PLAIDS
                              gmail.com            in the SPIN CYCLE --

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | comp.lang.python


csiph-web