Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from pulibrary/13-gdal-fix
Browse files Browse the repository at this point in the history
Expand rgb by default in gdal_translate command to hande color mapped geotiffs
  • Loading branch information
jrgriffiniii committed Oct 7, 2019
2 parents 23ec3dc + cfcfc09 commit a159751
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
sudo: true
language: ruby
rvm:
- 2.4.3
- 2.4.5
addons:
apt:
packages:
- libgdal1h
- libgdal1i
- libgdal-dev
- gdal-bin
- libcairo2-dev
Expand Down
3 changes: 3 additions & 0 deletions lib/geo_works/derivatives/processors/gdal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module Gdal
# @param out_path [String] processor output file path
# @param options [Hash] creation options
def self.translate(in_path, out_path, _options)
execute "gdal_translate -q -ot Byte -of GTiff -co TILED=YES -expand rgb -co COMPRESS=DEFLATE \"#{in_path}\" #{out_path}"
rescue StandardError
# Try without expanding rgb
execute "gdal_translate -q -ot Byte -of GTiff -co TILED=YES -co COMPRESS=DEFLATE \"#{in_path}\" #{out_path}"
end

Expand Down
2 changes: 1 addition & 1 deletion spec/geo_works/derivatives/processors/gdal_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def source_path; end

describe '#translate' do
it 'executes a gdal_translate command' do
command = "gdal_translate -q -ot Byte -of GTiff -co TILED=YES -co COMPRESS=DEFLATE \"files/geo.tif\" output/geo.png"
command = "gdal_translate -q -ot Byte -of GTiff -co TILED=YES -expand rgb -co COMPRESS=DEFLATE \"files/geo.tif\" output/geo.png"
processor.class.translate(file_name, output_file, options)
expect(processor.class).to have_received(:execute).with command
end
Expand Down

0 comments on commit a159751

Please sign in to comment.