File tree Expand file tree Collapse file tree 4 files changed +126
-0
lines changed
Expand file tree Collapse file tree 4 files changed +126
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM centos:6
2+
3+ # general build stuff
4+ RUN yum update -y \
5+ && yum groupinstall -y "Development Tools" \
6+ && yum install -y wget tar
7+
8+ # have to build our own ruby since centos6 ships with ruby1.8 and ruby-vips
9+ # needs 1.9+
10+
11+ # stuff for a ruby build
12+ RUN yum install -y \
13+ libxslt-devel \
14+ libyaml-devel \
15+ libxml2-devel \
16+ gdbm-devel\
17+ libffi-devel \
18+ zlib-devel \
19+ openssl-devel \
20+ libyaml-devel \
21+ readline-devel\
22+ curl-devel \
23+ openssl-devel \
24+ pcre-devel git \
25+ memcached-devel \
26+ valgrind-devel \
27+ mysql-devel
28+
29+ # stuff we need to build our own libvips ... this is a pretty random selection
30+ # of dependencies, you'll want to adjust these
31+ RUN yum install -y \
32+ libpng-devel \
33+ glib2-devel \
34+ libjpeg-devel \
35+ expat-devel \
36+ zlib-devel \
37+ openjpeg-devel \
38+ libtiff-devel \
39+ gdk-pixbuf2-devel \
40+ sqlite-devel \
41+ cairo-devel
42+
43+ # build latest ruby by default
44+ ARG RUBY_VERSION=2.5.1
45+ ARG RUBY_URL=https://cache.ruby-lang.org/pub/ruby/2.5
46+
47+ RUN cd /usr/local/src \
48+ && wget ${RUBY_URL}/ruby-${RUBY_VERSION}.tar.gz \
49+ && tar xzf ruby-${RUBY_VERSION}.tar.gz \
50+ && cd ruby-${RUBY_VERSION} \
51+ && ./configure \
52+ && make \
53+ && make install
54+
55+ ARG VIPS_VERSION=8.6.3
56+ ARG VIPS_URL=https://github.com/jcupitt/libvips/releases/download
57+
58+ RUN cd /usr/local/src \
59+ && wget ${VIPS_URL}/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.gz \
60+ && tar xzf vips-${VIPS_VERSION}.tar.gz \
61+ && cd vips-${VIPS_VERSION} \
62+ && ./configure \
63+ && make \
64+ && make install
65+
66+ # install the gem
67+ RUN yum install -y \
68+ ruby \
69+ rubygems
70+ RUN gem install ruby-vips
71+
72+ WORKDIR /data
Original file line number Diff line number Diff line change 1+ # Make a php-vips / nginx / ubuntu 16.04 stack
2+
3+ This doesn't work at the moment -- looks like glib 2.28.4 (the centos glib) is
4+ too old, perhaps?
5+
6+ # Rebuild the image
7+
8+ docker pull centos:6
9+
10+ docker build -t ruby-vips-centos6 .
11+
12+ # Run the demo
13+
14+ docker run --rm -t \
15+ -v $PWD:/data \
16+ ruby-vips-centos6 \
17+ ./wobble.rb test.jpg x.jpg
18+
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env ruby
2+
3+ require 'vips'
4+
5+ image = Vips ::Image . new_from_file ARGV [ 0 ]
6+
7+ module Vips
8+ class Image
9+ def wobble
10+ # this makes an image where pixel (0, 0) (at the top-left) has
11+ # value [0, 0], and pixel (image.width - 1, image.height - 1) at the
12+ # bottom-right has value [image.width - 1, image.height - 1]
13+ index = Vips ::Image . xyz width , height
14+
15+ # make a version with (0, 0) at the centre, negative values up
16+ # and left, positive down and right
17+ centre = index - [ width / 2 , height / 2 ]
18+
19+ # to polar space, so each pixel is now distance and angle in degrees
20+ polar = centre . polar
21+
22+ # scale sin(distance) by 1/distance to make a wavey pattern
23+ d = ( ( polar [ 0 ] * 3 ) . sin * 10000 ) / ( polar [ 0 ] + 1 )
24+
25+ # and back to rectangular coordinates again to make a set of
26+ # vectors we can apply to the original index image
27+ index += d . bandjoin ( polar [ 1 ] ) . rect
28+
29+ # finally, use our modified index image to distort!
30+ mapim index
31+ end
32+ end
33+ end
34+
35+ image = image . wobble
36+ image . write_to_file ARGV [ 1 ]
You can’t perform that action at this time.
0 commit comments