directus / v8-archive

Directus Database API — Wraps Custom SQL Databases with a REST/GraphQL API
https://docs.directus.io/api/reference.html
507 stars 204 forks source link

how to use 'format' query parameter to Thumbnail URLs from #1001 #1720

Open everyx opened 4 years ago

everyx commented 4 years ago

Hi, I found that Directus support format feature for thumbnail before via #1001 , but I can't find any document for it, and [thumbnail_url]?format=[format] is not work for v8.3.1.

benhaynes commented 4 years ago

I don't believe that we have the parameter to change formats for the thumbnail, but this is an interesting question. If you upload a PNG (with alpha layer), then I would expect a similar thumbnail (also with alpha layer). Similarly, (and this might be a lot harder), I would like to see animated gifs stay animated in their thumbnails.

Generally I think thumbs should use the same format as their parent, unless there's an override in the parameter. Thoughts @directus/team ?

rijkvanzanten commented 4 years ago

Absolutely @benhaynes, and that's also how it worked before. The idea being that you can upload a PNG, but request the thumbnail as WEBP or JPEG to save on bandwidth

EternalBlack commented 4 years ago

I kind of got the same question regarding webp support. Currently using the directus/directus:v8-apache docker image - do I need to install webp beforehand? Can't seem to get it to work or am just using it wrong😅

zerbfra commented 4 years ago

Same here

/assets/ji33epzhhl4448gw?w=600&h=600&f=contain&q=80&format=gif

does return a png without transparency (instead of a gif with trasparency) and

/assets/ji33epzhhl4448gw?w=600&h=600&f=contain&q=80&format=webp

says "Webp format is not supported by PHP installation."

zerbfra commented 4 years ago

Got rid of the message by editing the Dockerfile. You need to install this way:

#
RUN \
  apt-get update && \
  apt-get install -y git zip libpng-dev libjpeg-dev libzip-dev libfreetype6-dev libxml2-dev libwebp-dev libmagickwand-dev rsync && \
  rm -rf /var/lib/apt/lists/* && \
  docker-php-ext-configure zip --with-libzip && \
  docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-webp-dir=/usr/include && \
  docker-php-ext-install gd zip exif pdo pdo_mysql xml fileinfo mysqli && \
  pecl install imagick && pecl install redis && \
  docker-php-ext-enable imagick && docker-php-ext-enable redis

I added libwebp-dev and --with-webp-dir=/usr/include in the configure gd line.