PHP code example of marekskopal / lithophane

1. Go to this page and download the library: Download marekskopal/lithophane library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

marekskopal / lithophane example snippets


use MarekSkopal\Lithophane\Config\FrameType;
use MarekSkopal\Lithophane\Config\LithophaneConfig;
use MarekSkopal\Lithophane\Image\ImageLoader;
use MarekSkopal\Lithophane\LithophaneGenerator;

$config = new LithophaneConfig(width: 100, height: 150, frame: FrameType::HookTab);
$generator = new LithophaneGenerator();

// One shot: image file in, STL file out
$result = $generator->generate('photo.jpg', $config, 'photo.stl');
printf("%d triangles, %.1f × %.1f × %.1f mm\n", $result->triangles, $result->widthMm, $result->heightMm, $result->depthMm);

// Step by step, e.g. to also render a preview or count triangles first
$field = $generator->heightField(ImageLoader::fromFile('photo.jpg'), $config);
echo $generator->estimateTriangles($field), " triangles\n";
$generator->writeStl($field, 'photo.stl', $config->orientation);
$generator->writePreview($field, $config, 'photo.png');

use MarekSkopal\Lithophane\Config\LithophaneMakerSettings;

$settings = LithophaneMakerSettings::fromFile('settings-window-photo.txt');
$config = LithophaneConfig::fromArray(['resolution' => 0.3], $settings->config);
bash
php tools/stl-heightmap.php reference.stl fixture.png <frameWidth> <minThickness> <maxThickness>