Hey Noah,
Since the Ruby runtime runs on the Flexible Environment
<https://cloud.google.com/appengine/docs/flexible/>, you can use runtime:
custom
<https://cloud.google.com/appengine/docs/flexible/custom-runtimes/build> in
app.yaml and supply a Dockerfile (in which the first line will be "FROM gcr.
io/google_appengine/ruby") (see here
<https://github.com/GoogleCloudPlatform/ruby-docker> a link to the github
page of the Ruby runtime Docker image) which will install ImageMagick.
To install ImageMagick in the Dockerfile, you'd probably want to create a
script that the Dockerfile runs, which will group together the many
commands needed to install the dependencies and build from source. The
script would look something like the following:
#!/bin/bash
apt-get -y install \
build-essential \
checkinstall \
libx11-dev \
libxext-dev \
zlib1g-dev \
libpng12-dev \
libjpeg-dev \
libfreetype6-dev \
libxml2-dev
apt-get -y build-dep imagemagick
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar -xzvf ImageMagick.tar.gz
cd ImageMagick*
./configure
make
make install
... and the Dockerfile would include lines like:
ADD . /app/
RUN chmod +x /app/install-imagick.sh
RUN /app/install-imagick.sh
This will make ImageMagick available on the VM which runs your Ruby
process. You can then call the program from Ruby using any of the various
methods by which this can be done (see here a blog post
<http://mentalized.net/journal/2010/03/08/5-ways-to-run-commands-from-ruby/>
referencing 5 different ways to run commands from Ruby).
Although you could run ImageMagick to resize images dynamically on each
request, this is not the most efficient way to go about it if all you
require are thumbnails.
For thumbnails, I would recommend, whenever an image is uploaded, creating
a process that will use ImageMagick to create and store a resized version
for future use. You can use Cloud Pub/Sub <https://cloud.google.com/pubsub/>
to create "task queues" in this way. The basic steps would be:
1. Receive the image upload and store the full image in Cloud Storage
2. Push a message to the Pub/Sub topic you created to manage this workflow
(give it a name like "thumbnail-creation")
3. Have a pool of instances with ImageMagick installed who will subscribe
to this topic
4. When an instance receives a request corresponding to the published
message, have it download the image, and then resize and store the image as
a thumbnail
I hope this is helpful, let me know if you have any further questions; I'll
be happy to assist!
Cheers,
Nick
Cloud Platform Community Support
On Tuesday, October 4, 2016 at 11:20:10 AM UTC-4, Noah Hines wrote:
>
> Hello. I followed the Ruby on Rails Bookshelf App tutorial and built a
> basic web app where users can upload pictures. I would like to have
> server-side image resizing, so that when you get a list of all the images
> (from cloud datastore), you don't have to download huge versions of
> everything.
>
> It looks like all the other languages have support for resizing Datastore
> images. Is this something that is planned for Ruby? Is there a solution
> that will work for me in the meantime?
>
> I've explored using ImageMagick, but that would require installing a
> binary and I'm not sure if that's possible or a good idea.
>
> If there's a known solution, I'd love to hear it!
> Thanks.
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/ee185bb2-d453-44c7-abce-332c3a7b4bee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.