X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senfscons%2FDia2Png.py;h=3e5f0fe8739401b3bdd752cadfa3eb9538dd32db;hb=83df9651fac5af034774ff9314ee18eeb8a5ec2a;hp=d536ebfdde7b3fc2479a09c01fd81433cbf36a1f;hpb=ac6a813d9d99f7add4e13aff7a4bcd314d5604a6;p=senf.git diff --git a/senfscons/Dia2Png.py b/senfscons/Dia2Png.py index d536ebf..3e5f0fe 100644 --- a/senfscons/Dia2Png.py +++ b/senfscons/Dia2Png.py @@ -1,11 +1,25 @@ -"""Dia2Png SCons Builder: Build a PNG file given a DIA file. - -Support the specification of a scalefactor in the DIA2PNGDPI Environment variable. - -""" +## \file +# \brief Bia2Png builder + +## \package senfscons.Dia2Png +# \brief Build a PNG file from a DIA file +# +# This builder will convert a given DIA file into a PNG image. The +# size of the target file is specified by giving a preferred DPI value +# and a maximum width. The Builder will automatically fetch the +# correct aspect ratio from the dia file. +# +# \par Construction Envrionment Variables: +# +# +# +# +#
\c DIACOMdia command, defaults to \c diak
\c DIA2PNGDPIresolution of converted image, defaults to 115
\c DIA2PNGMAXWIDTHmaximum image width, defaults to 800
+# +# \ingroup builder import os -import SCons.Builder +import SCons.Builder, SCons.Action def dia_getSize(env,source): size = None @@ -17,12 +31,15 @@ def dia_getSize(env,source): def dia2png_generator(source, target, env, for_signature): if for_signature: - return "$DIACOM -t png -s $DIA2PNGDPI $TARGET $SOURCE" + return "$DIACOM -t png -s $DIA2PNGDPI,$DIA2PNGMAXWIDTH $TARGET $SOURCE" size = dia_getSize(env,source) if not size: return None; size[0] = size[0]*int(env['DIA2PNGDPI'])/72 size[1] = size[1]*int(env['DIA2PNGDPI'])/72 - return env.Action("$DIACOM -t png -s %dx%d -e $TARGET $SOURCE" % tuple(size)) + if size[0] > env['DIA2PNGMAXWIDTH']: + size[1] = size[1]*env['DIA2PNGMAXWIDTH']/size[0] + size[0] = env['DIA2PNGMAXWIDTH'] + return SCons.Action.Action("$DIACOM -t png -s %dx%d -e $TARGET $SOURCE" % tuple(size)) Dia2Png = SCons.Builder.Builder(suffix = ".png", src_suffix = ".dia", @@ -33,6 +50,7 @@ def generate(env): env['BUILDERS']['Dia2Png'] = Dia2Png env['DIACOM'] = "dia" env['DIA2PNGDPI'] = 115 + env['DIA2PNGMAXWIDTH'] = 800 def exists(env): return env.Detect("dia")