Product Family

Create your Lithophane from GIF via Java

Create your Lithophane from GIF using Java library without any 3D modeling software.

How to Create your Lithophane from GIF File Using Java

In order to create your lithophane from GIF file, we’ll use

Aspose.3D for Java

API which is a feature-rich, powerful and easy to use lithophane API for Java platform. You can download its latest version directly from

Aspose Maven Repository

and install it within your Maven-based project by adding the following configurations to the pom.xml.


<name>Aspose Java API</name>


<version>version of aspose-3d API</version>

Steps to Create your Lithophane from GIF via Java

Java programmers can easily create your lithophane from GIF in just a few lines of code.

  • Create some new parameters and create a Mesh object
  • Perform computational operations on Mesh objects
  • GIF file loads 3d scene through Mesh class
  • Call the Scene.Save method with object

System Requirements

Aspose.3D for JAVA is supported on all major operating systems. Just make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
  • Get latest version of Aspose.3D for Java directly from Maven.

JAVA code to Create your Lithophane from GIF

//The original image that needs to be uploaded and the 3d file output after saving
String file = "template.gif";
String output = "outFile.fbx";

//Create some new parameters
TextureData td= TextureData.fromFile(file);
final float nozzleSize = 0.9f;//0.2mm
final float layerHeight = 0.2f;
float[][] grayscale = ToGrayscale(td);
final float width = 120.0f;//canvas width is 200.0mm
float height = width / td.getWidth() * td.getHeight();
float thickness = 10.0f;//10mm thickness
float layers = thickness / layerHeight;
int widthSegs = (int)Math.floor(width / nozzleSize);
int heightSegs = (int)Math.floor(height / nozzleSize);

//Perform computational operations on Mesh objects
Mesh mesh = new Mesh();
for (int y = 0; y < heightSegs; y++)
    float dy = (float)y / heightSegs;
    for (int x = 0; x < widthSegs; x++)
        float dx = (float)x / widthSegs;
        float gray = Sample(grayscale, td.getWidth(), td.getHeight(), dx, dy);
        float v = (1 - gray) * thickness;
        mesh.getControlPoints().add(new Vector4(dx * width, dy * height, v));

for (int y = 0; y < heightSegs - 1; y++)
    int row = (y * heightSegs);
    int ptr = row;
    for (int x = 0; x < widthSegs - 1; x++)
        mesh.createPolygon(ptr, ptr + widthSegs, ptr + 1);
        mesh.createPolygon(ptr + 1, ptr + widthSegs, ptr + widthSegs + 1);

//Generate 3d scene and save objects
Scene scene = new Scene(mesh);, FileFormat.FBX7400ASCII);

//The sample method to call
static float Sample(float[][] data, int w, int h, float x, float y)
    return data[(int)(x * w)][(int)(y * h)];

//ToGrayscale method to call
static float[][] ToGrayscale(TextureData td)
    float[][] ret = new float[td.getWidth()][td.getHeight()];
    int stride =td.getStride();
    byte[] data = td.getData();
    int bytesPerPixel = td.getBytesPerPixel();
    for (int y = 0; y < td.getHeight(); y++)
        int ptr = y * stride;
        for (int x = 0; x < td.getWidth(); x++)
            float v = (data[ptr] * 0.21f + data[ptr + 1] * 0.72f + data[ptr + 2] * 0.07f) / 255.0f;
            ret[x][y] = v;
            ptr += bytesPerPixel;
    return ret;
  • Free App to Create your Lithophane from GIF

    Lithophane GIF right now by visiting our Live Demos website.The live demo has the following benefits

      No need to download Aspose API.
      No need to write any code.
      Just upload GIF file and hit the "lithophane" button
      You will get the download link.

    Java 3D Scene Manipulation Library

    Aspose.3D is a CAD and Gameware API to load, modify and convert 3D files. API is a standalone and does not require any any 3D modeling or rendering software. One can easily use API for Discreet3DS, WavefrontOBJ, STL (ASCII, Binary), Universal3D, FBX (ASCII, Binary), Collada, glTF, PLY, GLB, DirectX and more formats.

    GIF What is GIF File Format?

    A GIF or graphical interchange format is a type of highly compressed image. Owned by Unisys, GIF uses the LZW compression algorithm that does not degrade the image quality. For each image GIF typically allow up to 8 bits per pixel and up to 256 colours are allowed across the image. In contrast to a JPEG image, which can display up to 16 million colours and fairly touches the limits of the human eye.

    Read More

    Other Supported App to Create your Lithophane from Formats

    Using JAVA, One can also create your lithophane from many other file formats including.

    JPEG (Joint Photographic Experts Group)
    PNG (Portable Network Graphics)
    TGA (Truevision Advanced Raster Adapter)
    BMP (Bitmap)
    JPG (Joint Photographic Experts Group)
    GIF (Graphical Interchange Format)
    TIFF (Tagged Image File Format)