Skip to content

Commit

Permalink
refactor(png): add support to convert the png file to a suitable colo…
Browse files Browse the repository at this point in the history
…r model at the time to convert the image to a pdf format
  • Loading branch information
danvergara committed Jan 16, 2024
1 parent 177ebd4 commit 0aa740e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/files/images/png.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package images
import (
"bytes"
"fmt"
"image"
"image/draw"
"image/png"
"slices"
"strings"
Expand Down Expand Up @@ -75,7 +77,10 @@ func (p *Png) ConvertTo(fileType, subType string, fileBytes []byte) ([]byte, err
return nil, err
}

result, err = convertToDocument(subType, img)
rgba := image.NewRGBA(img.Bounds())
draw.Draw(rgba, img.Bounds(), img, image.Point{}, draw.Src)

result, err = convertToDocument(subType, rgba)
if err != nil {
return nil, fmt.Errorf(
"ConvertTo: error at converting image to another format: %w",
Expand Down

0 comments on commit 0aa740e

Please sign in to comment.