I want to make a package where some variables are initialized to images. but when i save the package, all images are in the form of ImageData that are very long. how do i fix it ?

  • $\begingroup$ If the package works, there's nothing to be fixed. Note that you can't store an image in a "visible" way in a plain text (.m) file. $\endgroup$
    – Szabolcs
    Commented Jan 17, 2013 at 2:13
  • 1
    $\begingroup$ Are you certain that the images are being stored in the package with head ImageData? I would have expected them to be stored with head Image, which is quite different (preserves the image metadata). $\endgroup$
    – m_goldberg
    Commented Jan 17, 2013 at 2:16
  • $\begingroup$ You can store as compressed strings and uncompress during an initialization. $\endgroup$ Commented Jan 17, 2013 at 2:21
  • $\begingroup$ Sorry it is stored as Image.A simple image is stored as follows Image[CompressedData[" 1:eJxTTMoPSmNiYGAo5gASQYnljkVFiZXBLECOU2VJahJIShyI5YD4P33Av7// cEv+BWHc8t+efMBl6r8PdlwsrAEv/v3FJvv/sfeCI3OZ3f5jkwXJA0E9w5f/ 2K3++/vb/0zuXzhkgWA3Q9f/P9hN/vu5irkKh7VAPQcZNuPQCZLdx/DuDw6t QPDrJS6dIB/d7XqJ08F//m9kOIfLUUDw49kvnHIEAW5jqQ0AKuOioA== "], "Byte", ColorSpace -> "Grayscale", Interleaving -> None] $\endgroup$
    – santhosh
    Commented Jan 17, 2013 at 2:24
  • 1
    $\begingroup$ Then what do you want to do? What is your definition of "fixing it"? $\endgroup$
    – rm -rf
    Commented Jan 17, 2013 at 3:34

1 Answer 1


I´d recommend working in the frontend with the package stylesheet. You get all the fancy frontend features (typesetting, graphics...) but the file is maintained in package (.m) format.

All cells with the Code style will be carried over into the package (in fact they are initialization cells). Upon opening, the content is parsed and displayed as an ordinary notebook.

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.