Brad
Brad

Reputation: 21

Openseadragon, DeepZoom, WordPress

Trying to setup OpenSeadragon for a WordPress site. Just testing around now and trying to get the zoom feature to work.

I've tried including the DeepZoom tile generator without success and continue getting a "Fatal error: Uncaught Error: Class 'League\Flysystem\Filesystem' not found" error.

The only other DZI generator I see that might work is a Windows desktop app which won't work, I'm on a mac.

This is what I have so far (just working of examples provided by openseadragon and deepzoom):

I'm including Deepzoom.php and DeepzoomFactory.php in my functions file.

<div id="primary" class="content-area zoom">
    <main id="main" class="site-main">

    <?php
    // Setup Deepzoom
    $deepzoom = Jeremytubbs\Deepzoom\DeepzoomFactory::create([
        'path' => '/wp-content/uploads/DZI/ready/', // Export path for tiles
        'driver' => 'imagick', // Choose between gd and imagick support.
        'format' => 'jpg',
    ]);
    // folder, file are optional and will default to filename
    $response = $deepzoom->makeTiles('/wp-content/uploads/DZI/oklahoma.jpg');
    ?>

    <div id="openseadragon1" style="width: 800px; height: 600px;"></div>
    <script src="<?php echo get_template_directory_uri() ; ?>/lib/openseadragon/openseadragon.min.js"></script>
    <script type="text/javascript">
        var viewer = OpenSeadragon({
            id: "openseadragon1",
            prefixUrl: "/wp-content/themes/truelook/lib/openseadragon/images/",
            tileSources: <?php echo $response; ?>
        });
    </script>

Any suggestions or advice pointing me in the right directio would be most welcome. Thanks!

Upvotes: 1

Views: 924

Answers (3)

jcupitt
jcupitt

Reputation: 11190

libvips has dzsave, which can make deepzoom pyramids of any size very quickly. There's a chapter in the docs about it.

You can install on a mac with homebrew, macports, fink etc. For example:

brew install vips

Then make the pyramid with:

vips dzsave oklahoma.jpg x

and it'll create x_files and x.dzi (use a different name, of course).

You can also use php-vips (the PHP binding for libvips) to create pyramids. Something like:

$im = Vips\Image::newFromFile('oklahoma.jpg', 
    ['access' => Vips\Access::SEQUENTIAL]);
$im->dzsave('x');

It might be fast enough for on-the-fly generation, it depends on the image size, format and your requirements. On this 2015 laptop with a 10k x 10k pixel RGB image I see:

$ /usr/bin/time -f %M:%e vips dzsave wtc.jpg x
98856:3.93

So 100mb of memory and 4s of elapsed time.

Upvotes: 1

HamidReza Abdipour
HamidReza Abdipour

Reputation: 11

To make the deepzoom run, you should install dependencies with composer. First clone the deepzoom repository. Get into repo dir and run php composer install command. Composer Docs to install dependencies After the isntallation completed, add this line above your codes:

require 'deepzoom/vendor/autoload.php';

Note that you should use absolute path for 'path' and filename parameters. Example:

$deepzoom = Jeremytubbs\Deepzoom\DeepzoomFactory::create([
    'path' => '/home/username/public_html/wp-content/uploads/DZI', // Export path for tiles. Do not add / end of path
    'driver' => 'imagick', // Choose between gd and imagick support.
    'format' => 'jpg',
]);

$response = $deepzoom->makeTiles('/home/username/public_html/wp-content/uploads/2020/1/image.jpg');

Do not include this code in your template file. Create another .php file and pass the file name.

Upvotes: 0

buzibuzi
buzibuzi

Reputation: 734

have you seen this Zoom OpenSeadragon plugin ? it outdated but it might help you make the backed operation smoother.

Upvotes: 0

Related Questions