Yahoo Groups archive

Digital BW, The Print

Index last updated: 2026-04-28 22:56 UTC

Message

Re: [Digital BW] software tool for measuring matts

2010-01-19 by Andrew Sharpe

Well, having been a UNIX guy for 30 years, I just wrote a tiny python
script to take care of the one annoyance I have with mat borders: I
like to measure things in mm, but the standard sizes of mats are in
inches. I haven't used it to cut mats yet, but it looks like it's
producing the right numbers. If it doesn't work, let me know.

This program will run anywhere python runs, which includes Linux,
Windows, and Macs. I'm planning on making it a bit nicer, like
adding the ability to have the lower border larger, but you get
the general idea. That MatWorks program was 6 megabytes; this script
is ~1200 bytes. I'm not really trying to compare this tiny program
against probably a very good, graphical program. But, between paper
and pencil and this program, isn't this about what's necessary?

I'll paste it here; I'd rather attach it, but I don't think
attachments will survive the group posting, and I looked at
the files section of the yahoo group page, but it doesn't
seem to allow uploads.

If you can't read it, let me know and I'll email it to you directly.
It's really quite trivial.

Here's a sample output:

$ mat.py 
Photo width (mm): 177.8
Photo height (mm): 228.6
Mat width (11 in): 16
Mat height (14 in): 20
Overlap (0.25 in): 
Left border = 117mm
Top border = 143mm

Defaults are in parentheses; if you want paper to show around the
photograph, use a negative overlap.

Andrew


#!/usr/bin/python                                                                                   
#                                                                                                   
# Compute mat borders                                                                               
#                                                                                                   
# Andrew Sharpe 2010                                                                                
#                                                                                                   
import os
import sys
#                                                                                                   
# in inches                                                                                         
#                                                                                                   
MAT_WIDTH = 11
MAT_HEIGHT = 14
OVERLAP = .25


def mm(inches):
   return (float(inches) * 25.4)

def get_num(prompt, default):
   a = raw_input(prompt)
   if not a:
      a = default
   return float(a)


def main():
   try:
      while True:
         photo_width = get_num("Photo width (mm): ", 0)
         photo_height = get_num("Photo height (mm): ", 0)
         if not photo_width or not photo_height:
            print ("Photo height or width may not be zero")
         else:
            break

      mat_width = mm(get_num("Mat width (" + str(MAT_WIDTH) + " in): ", MAT_WIDTH))
      mat_height = mm(get_num("Mat height (" + str(MAT_HEIGHT) + " in): ", MAT_HEIGHT))
      mat_overlap = mm(get_num("Overlap (" + str(OVERLAP) + " in): ", OVERLAP))         

      lborder = round((mat_width - (photo_width - mat_overlap)) / 2.0)
      tborder = round((mat_height - (photo_height - mat_overlap)) / 2.0)
      print "Left border = %dmm" % lborder
      print "Top border = %dmm" % tborder
      return 0

   except Exception, msg:
      print "Exception", str(msg)
      return 1

if __name__ == "__main__":
   sys.exit(main())



On 01/18/2010 05:26 AM, David Kachel wrote:
>  
> 
> 
> On Jan 18, 2010, at 7:06 AM, Mark Savoia wrote:
> 
>> I see. Will it run an a Mac?
> 
> I built it on a Mac, though I can package it for Windows too.
> 
> David Kachel
> 
> [Non-text portions of this message have been removed]
> 
> 

-- 
http://andrewsharpe.com


[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.