Skip to content

Commit

Permalink
Allow all x64_64 to use pre-built images, not just recent processors.…
Browse files Browse the repository at this point in the history
… Make golint slightly happier. Refactor webp vs preview format selection.
  • Loading branch information
aaron42net committed Apr 8, 2016
1 parent ffa59d8 commit 8e158df
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RUN \
apt-get -q update && \ apt-get -q update && \
apt-get -y -q dist-upgrade && \ apt-get -y -q dist-upgrade && \
# Apt-get our dependencies, download, build, and install VIPS, and download and install Go. # Apt-get our dependencies, download, build, and install VIPS, and download and install Go.
DEBIAN_FRONTEND=noninteractive CFLAGS="-O2 -ftree-vectorize -msse4.2 -ffast-math" VIPS_OPTIONS="--disable-gtk-doc-html --disable-pyvips8 --without-cfitsio --without-fftw --without-gsf --without-matio --without-openslide --without-orc --without-pangoft2 --without-python --without-x --without-zip" \ DEBIAN_FRONTEND=noninteractive CFLAGS="-O2 -ftree-vectorize -msse2 -ffast-math" VIPS_OPTIONS="--disable-gtk-doc-html --disable-pyvips8 --without-cfitsio --without-fftw --without-gsf --without-matio --without-openslide --without-orc --without-pangoft2 --without-python --without-x --without-zip" \
/app/src/github.com/die-net/fotomat/preinstall.sh && \ /app/src/github.com/die-net/fotomat/preinstall.sh && \


# Create a few directories # Create a few directories
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dpkg-jessie
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ADD preinstall.sh /app/src/github.com/die-net/fotomat/


RUN \ RUN \
# Apt-get our dependencies, download, build, and install VIPS, and download and install Go. # Apt-get our dependencies, download, build, and install VIPS, and download and install Go.
DEBIAN_FRONTEND=noninteractive CFLAGS="-O2 -ftree-vectorize -msse4.2 -ffast-math -fPIC" VIPS_OPTIONS="--disable-shared --enable-static" \ DEBIAN_FRONTEND=noninteractive CFLAGS="-O2 -ftree-vectorize -msse2 -ffast-math -fPIC" VIPS_OPTIONS="--disable-shared --enable-static" \
/app/src/github.com/die-net/fotomat/preinstall.sh && \ /app/src/github.com/die-net/fotomat/preinstall.sh && \
# Add dpkg build tool. # Add dpkg build tool.
DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends fakeroot && \ DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends fakeroot && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dpkg-stretch
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ADD preinstall.sh /app/src/github.com/die-net/fotomat/


RUN \ RUN \
# Apt-get our dependencies, download, build, and install VIPS, and download and install Go. # Apt-get our dependencies, download, build, and install VIPS, and download and install Go.
DEBIAN_FRONTEND=noninteractive CFLAGS="-O2 -ftree-vectorize -msse4.2 -ffast-math -fPIC" VIPS_OPTIONS="--disable-shared --enable-static" \ DEBIAN_FRONTEND=noninteractive CFLAGS="-O2 -ftree-vectorize -msse2 -ffast-math -fPIC" VIPS_OPTIONS="--disable-shared --enable-static" \
/app/src/github.com/die-net/fotomat/preinstall.sh && \ /app/src/github.com/die-net/fotomat/preinstall.sh && \
# Add dpkg build tool. # Add dpkg build tool.
DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends fakeroot && \ DEBIAN_FRONTEND=noninteractive apt-get install -y -q --no-install-recommends fakeroot && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.rpm-centos6
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ADD preinstall.sh /app/src/github.com/die-net/fotomat/


RUN \ RUN \
# Install our dependencies. Download, build, and install VIPS. Download and install Go. # Install our dependencies. Download, build, and install VIPS. Download and install Go.
CFLAGS="-O2 -ftree-vectorize -msse4.2 -ffast-math -fPIC" LDFLAGS="-lstdc++" VIPS_OPTIONS="--disable-shared --enable-static" \ CFLAGS="-O2 -ftree-vectorize -msse2 -ffast-math -fPIC" LDFLAGS="-lstdc++" VIPS_OPTIONS="--disable-shared --enable-static" \
/app/src/github.com/die-net/fotomat/preinstall.sh && \ /app/src/github.com/die-net/fotomat/preinstall.sh && \
# Add a tool for building RPMs. # Add a tool for building RPMs.
yum -y install rpm-build yum -y install rpm-build
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.rpm-centos7
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ADD preinstall.sh /app/src/github.com/die-net/fotomat/


RUN \ RUN \
# Install our dependencies. Download, build, and install VIPS. Download and install Go. # Install our dependencies. Download, build, and install VIPS. Download and install Go.
CFLAGS="-O2 -ftree-vectorize -msse4.2 -ffast-math -fPIC" LDFLAGS="-lstdc++" VIPS_OPTIONS="--disable-shared --enable-static" \ CFLAGS="-O2 -ftree-vectorize -msse2 -ffast-math -fPIC" LDFLAGS="-lstdc++" VIPS_OPTIONS="--disable-shared --enable-static" \
/app/src/github.com/die-net/fotomat/preinstall.sh && \ /app/src/github.com/die-net/fotomat/preinstall.sh && \
# Add a tool for building RPMs. # Add a tool for building RPMs.
yum -y install rpm-build yum -y install rpm-build
Expand Down
2 changes: 1 addition & 1 deletion cmd/fotomat/cpu.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// Attempt to guess the number of physical (non-hyperthread) cores // Attempt to guess the number of physical (non-hyperthread) cores
// available. If that doesn't work, return Go's count of virtual cores that // available. If that doesn't work, return Go's count of virtual cores that
// we can be scheduled on. // we can be scheduled on.
func numCpuCores() int { func numCPUCores() int {
cpus := runtime.NumCPU() cpus := runtime.NumCPU()


cores := procCpuinfoCores() cores := procCpuinfoCores()
Expand Down
21 changes: 9 additions & 12 deletions cmd/fotomat/handle.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ var (
lossyIfPhoto = flag.Bool("lossy_if_photo", true, "Save as lossy if image is detected as a photo.") lossyIfPhoto = flag.Bool("lossy_if_photo", true, "Save as lossy if image is detected as a photo.")
losslessWebp = flag.Bool("lossless_webp", false, "When saving in WebP, allow lossless encoding.") losslessWebp = flag.Bool("lossless_webp", false, "When saving in WebP, allow lossless encoding.")
maxBufferPixels = flag.Int("max_buffer_pixels", 6500000, "Maximum number of pixels to allocate for an intermediate image buffer.") maxBufferPixels = flag.Int("max_buffer_pixels", 6500000, "Maximum number of pixels to allocate for an intermediate image buffer.")
maxImageThreads = flag.Int("max_image_threads", numCpuCores(), "Maximum number of threads simultaneously processing images (0=all CPUs).") maxImageThreads = flag.Int("max_image_threads", numCPUCores(), "Maximum number of threads simultaneously processing images (0=all CPUs).")
maxOutputDimension = flag.Int("max_output_dimension", 2048, "Maximum width or height of an image response.") maxOutputDimension = flag.Int("max_output_dimension", 2048, "Maximum width or height of an image response.")
maxPrefetch = flag.Int("max_prefetch", numCpuCores(), "Maximum number of images to prefetch before thread is available.") maxPrefetch = flag.Int("max_prefetch", numCPUCores(), "Maximum number of images to prefetch before thread is available.")
maxProcessingDuration = flag.Duration("max_processing_duration", time.Minute, "Maximum duration we can be processing an image before assuming we crashed (0=disable).") maxProcessingDuration = flag.Duration("max_processing_duration", time.Minute, "Maximum duration we can be processing an image before assuming we crashed (0=disable).")
sharpen = flag.Bool("sharpen", false, "Sharpen after resize.") sharpen = flag.Bool("sharpen", false, "Sharpen after resize.")


Expand Down Expand Up @@ -83,22 +83,19 @@ func director(req *http.Request) (thumbnail.Options, int) {
}, },
} }


// Preview images are tiny, blurry JPEGs. if webp {
o.Save.AllowWebp = true
o.Save.Lossless = *losslessWebp
}

// Preview images are tiny, blurry JPEGs/lossy WebPs.
if preview { if preview {
o.Sharpen = false o.Sharpen = false
o.BlurSigma = 0.4 o.BlurSigma = 0.4
o.Save.Format = format.Jpeg o.Save.Lossless = false
o.Save.Quality = 40 o.Save.Quality = 40
} }


if webp {
o.Save.AllowWebp = true
if o.Save.Format != format.Unknown {
o.Save.Format = format.Webp
}
o.Save.Lossless = *losslessWebp
}

return o, 0 return o, 0
} }


Expand Down
4 changes: 2 additions & 2 deletions cmd/fotomat/version.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
) )


const ( const (
// Updated by git-hooks/pre-commit // FotomatVersion is updated by git-hooks/pre-commit
FotomatVersion = "2.4.172" FotomatVersion = "2.4.173"
) )


var ( var (
Expand Down
4 changes: 2 additions & 2 deletions thumbnail/icc.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion thumbnail/options.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (o Options) ToJSON() ([]byte, error) {
return buf.Bytes(), nil return buf.Bytes(), nil
} }


// FromJSON returns Options from a JSON representation of it. // OptionsFromJSON returns Options from a JSON representation of it.
func OptionsFromJSON(j []byte) (Options, error) { func OptionsFromJSON(j []byte) (Options, error) {
o := Options{} o := Options{}
if err := json.Unmarshal(j, &o); err != nil { if err := json.Unmarshal(j, &o); err != nil {
Expand Down

0 comments on commit 8e158df

Please sign in to comment.