Message Boards Message Boards

Rotate a binary embedded image in a graphic containing Postscript?

Posted 4 years ago

We have a collection of old notebooks containing cells with Postscript graphics. They relied on various external programs to help generate them so I can't regenerate these easily in a newer version of Wolfram Language. The notebooks open in a Front End without a problem and any of the Postscript that isn't read in with the currentfile command renders fine. Unfortunately, when a graphic contains an embedded image, the embedded image may be rendered upside down.

In the image below, the label 689 is rendered properly, but the CA graphic should be rotated 180 degrees. I can't rotate the whole image without rotating the label. This is a simple example and there are others with grids of small images with labels and just those images need 180 degree rotations. I've added a notebook with the image below to see if anyone has an idea as to how to get this working.

I've tried the following: 1. extracted the cell into a .m file 2. inserted rotation and other postscript commands to attempt to rotate the graphic just a little bit (eg rotate 5 or change the transformation matrix) 3. ran the .m through WolframKernel to export a png graphic

This fails as even "rotate 5" seemingly fails to rotate the coord system. Translate commands move the graphic object, but rotate doesn't rotate. I'm not sure why.

I've consulted others about this, but I can't find an expert on Mathematica and Postscript who might be able to give some advice.

CA upside down

"Show Expression" for one of this graphic cell (where the ... is information not displayed below):

Cell[GraphicsData["PostScript", "\<\
%!
%%Creator: Mathematica
%%AspectRatio: .81
MathPictureStart...
% Start of user PostScript
2
gsave
Mabswid
currentlinewidth
dup
grestore
2 copy translate
exch
2 mul
1 exch sub exch
2 mul
0.81 exch sub
0.81 div
scale
% End of user PostScript
% Start of user PostScript
gsave
1.000000 0.810000 scale
243 string
100 81 8 [100 0 0 -81 0 81]
\t{ currentfile 1 index readhexstring pop }
false 3 colorimage
00FF00FF0000FF00000000FF00FF00FF0000FF000000FF00FF0000FF0000FF0000FF0000FF00000000FFFF000000FF0000FF0000\
...
000000FF00FF0000FF000000FF0000FFFF0000FF0000FF00000000FF0000FF0000FF0000FF0000FF

pop
grestore

% End of user PostScript
MathSubEnd
P
% End of sub-graphic
0 g
p
/Courier findfont 10 scalefont setfont
[(689)] .5 0 0 1 Mshowa
P
0 0 m
1 0 L
1 .81 L
0 .81 L
closepath
clip
newpath
% End of Graphics
MathPictureEnd
\
\>"], "Graphics",
Evaluatable->False,
AspectRatioFixed->True,
ImageSize->{282, 228},
ImageMargins->{{34, Inherited}, {Inherited, Inherited}}]

Attachments:
POSTED BY: Roger Dooley
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract