ruby-on-railsrubyopenseadragon

How to use DZT gem inside the model?


I have a feeling my question might have a very easy answer. I am working on a Rails 6.1 solution that uses openseadragon to view, zoom and annotate large images. The solution requires the uploaded file to be 'tiled' to a DZI format. I found the 'dzt' gem that should do the trick. I added the gem to the gem file and ran "bundle install".

The instructions (https://github.com/dblock/dzt) show:

dzt slice image.jpg --output tiles

This works fine from the command line, the 'tiles' folder is created etc. But when I try to run the command from inside a model or the ruby IRB. I get this error:

SyntaxError ((irb):1: syntax error, unexpected tIDENTIFIER, expecting do or '{' or '(') dzt slice image.jpg --output tiles

I have tried adding require "dzt" to the model class but it does not seem to make a difference. Any suggestions as to where I am going wrong?


Solution

  • I figured it out. I just needed to put the command in back-ticks and it works.

    `dzt slice image.jpg --output tiles`