-
Notifications
You must be signed in to change notification settings - Fork 265
Optimizer fix for the CCITTFax Encoder. ISS #243. Fixes JBIG2 i386 architecture compile issue. #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## development #297 +/- ##
===============================================
+ Coverage 52.34% 62.23% +9.89%
===============================================
Files 235 235
Lines 45395 45395
===============================================
+ Hits 23760 28251 +4491
+ Misses 18583 16498 -2085
+ Partials 3052 646 -2406
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. I left one suggestion regarding the handling of the update parameters.
model/image.go
Outdated
@@ -98,7 +98,9 @@ func (img *Image) ConvertToBinary() error { | |||
func (img *Image) GetParamsDict() *core.PdfObjectDictionary { | |||
params := core.MakeDict() | |||
params.Set("Width", core.MakeInteger(img.Width)) | |||
params.Set("Columns", core.MakeInteger(img.Width)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to handle this scenario in the UpdateParams
method of the CCITTFaxEncoder
, instead of adding more keys here and in the getParamsDict
method of the XObjectImage
. This way, we have the handling in one place and we can update the encoders in a generic manner as well.
Something like this should work:
func (enc *CCITTFaxEncoder) UpdateParams(params *PdfObjectDictionary) {
// ...
if columns, err := GetNumberAsInt64(params.Get("Columns")); err == nil {
enc.Columns = int(columns)
} else if columns, err = GetNumberAsInt64(params.Get("Width")); err == nil {
enc.Columns = int(columns)
}
//...
if rows, err := GetNumberAsInt64(params.Get("Rows")); err == nil {
enc.Rows = int(rows)
} else if rows, err = GetNumberAsInt64(params.Get("Height")); err == nil {
enc.Rows = int(rows)
}
//...
}
FlateEncoder
also has Columns
, but it handles Width
in the UpdateParams
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, good idea.
GetParamsDict Columns and Rows parameters from model.Image and model.XObjImage.
Added 386 architecture to the .travis/cross_build.sh. Also fixed JBIG2 build error on i386 arch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This pull request fixes issue #243. Optimizer were panicing as the CCITTFax Encoder Columns were not updated with the UpdateParams method.
All DecodeParams updated only Width and Height whereas CCITTFax required 'Columns' and 'Rows' to be set. Currently
*model.XObjImage.getParamsDict()
as well as*model.Image GetParamsDict()
functions updatesWidth
,Height
,Columns
andRows
.This PR provide also integration tests for the optimized files. All
.pdf
files in the directory defined by environment variable:UNIDOC_OPTIMIZE_TESTDATA
are optimized with the maximum PPI of100
. Then the hash value of optimized files are kept in the golden file.This change is