Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Create jpg image files of mathematical equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102546] Re: Create jpg image files of mathematical equations
  • From: David Reiss <dbreiss at gmail.com>
  • Date: Thu, 13 Aug 2009 03:21:10 -0400 (EDT)
  • References: <h5okvi$sn$1@smc.vnet.net> <h5r8a5$l41$1@smc.vnet.net>

Hi Diana,

There are of course an infinite number of ways to approach this, and
all sorts of embellishments and efficiencies that can be added.  Here
is one approach that I cooked up for your particular case (times
tables).


First define a function to do the work for one case:


ClearAll[SaveEquation];

SaveEquation::dir =
  "The directory `1` does note exist.  Please create it first.";

SaveEquation[mValue_Integer, nValue_Integer, dir_String] :=

 Catch@Module[{problemFile, solutionFile},

   If[FileType[dir] =!= Directory,
    Throw[Message[SaveEquation::dir, dir]; $Failed]];

   problemFile =
    ToFileName[dir,
     ToString[mValue] <> "Times" <> ToString[nValue] <>
"Problem.jpg"];

   solutionFile =
    ToFileName[dir,
     ToString[mValue] <> "Times" <> ToString[nValue] <> "Equals" <>
      ToString[mValue nValue] <> "Solution.jpg"];

   Function[{m, n},
     Export[problemFile,
       ExpressionCell[Defer[m \[Cross] n ], "Input", FontSize -> 30,
       Background -> LightGray], "JPG"]][mValue, nValue];

   Function[{m, n},
     Export[solutionFile,
       ExpressionCell[Defer[m \[Cross] n == #] &[m  n], "Input",
       FontSize -> 30, Background -> LightGray]]][mValue, nValue]

   ]



Now use this function on a list of integers as in

SaveEquation[#, 14, "/Users/dreiss/Desktop/test/"] & /@ Range[14]


where, of course the directory path "/Users/dreiss/Desktop/test/"]
should be replaced with one that points to an existing directory on
your hard disk.

Best regards,

David


On Aug 12, 4:32 am, Diana <diana.me... at gmail.com> wrote:
> David,
>
> Thank you for explaining how to do the export with ExpressionCell.
>
> I have a two part followup:
>
> 1) I want to do hundreds of these files, and would like to use a table
> and variables which change. Is it possible to use "m" and "n" within
> the ExpressionCell[Defer[1 + 91}, for example, so that I don't have to
> rewrite each export statement?
>
> 2) I would like to make the file names dynamic. For example, if I am
> adding 1 + 91 = 92, I would like to name the file 01019192.jpg, where
> the leading 01 stands for addition, and the remaining string 019192
> stand for 1, 91, and the sum, respectively.
>
> As an example, I would like to be able to write one statement to
> create 14 jpg files for the "14's" times tables, 1 x 14 = 14, 2 x 14 =
= 28, ..., 14 x 14 = 196.
>
> Thank you for your time,
>
> Diana M.
>
> On Aug 11, 12:57 am, David Reiss <dbre... at gmail.com> wrote:
>
>
>
> > Here are two examples to get you started (of course the paths to the
> > files need to be changed for your system)....
>
> > Export["/Users/dreiss/Desktop/MyEquation.jpg",
> >  ExpressionCell[Defer[1 + 91], "Input", FontSize -> 30,
> >   Background -> LightGray]]
>
> > Export["/Users/dreiss/Desktop/MyEquation.jpg",
> >  ExpressionCell[Defer[1 + 91 == #] &[1 + 91], "Input", FontSize -=
> 30,
> >    Background -> LightGray]]
>
> > Hope this helps,
>
> > Davidhttp://www.scientificarts.com/worklife/
>
> > On Aug 10, 4:15 am, Diana <diana.me... at gmail.com> wrote:
>
> > > Hi all,
>
> > > I want to quickly create many jpg image files of math facts though 24=
,
> > > such as
>
> > > 12 + 12 = 24
> > > 30 - 15 = 15
> > > 3 x 4 = 12
>
> > > I would like to create the files with and without answers, with very
> > > large font, and with an option to choose font and background colors.
>
> > > Can someone explain how to export equations, with special characters
> > > for +, - * and /?
>
> > > Thank you,
>
> > > Diana



  • Prev by Date: Re: Create jpg image files of mathematical equations
  • Next by Date: Re: Create jpg image files of mathematical equations
  • Previous by thread: Re: Create jpg image files of mathematical equations
  • Next by thread: Re: Create jpg image files of mathematical equations