dont read local image file if target exists
This commit is contained in:
parent
567cd1646e
commit
9c0d959181
@ -152,6 +152,12 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
|
||||
if strings.HasPrefix(imgSource, "http://") || strings.HasPrefix(imgSource, "https://") {
|
||||
// remote file
|
||||
img, p.Format, err = getImageFromURL(imgSource)
|
||||
if err != nil {
|
||||
return nil, &pongo2.Error{
|
||||
Sender: "filter:image_resize",
|
||||
OrigError: fmt.Errorf("could not open image '%s': %s", imgSource, err),
|
||||
}
|
||||
}
|
||||
// build filename
|
||||
if p.Filename == "" {
|
||||
var fBase string
|
||||
@ -170,7 +176,6 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
|
||||
} else {
|
||||
// local file
|
||||
imgSource = ResolveInputPath(imgSource)
|
||||
img, err = imaging.Open(imgSource, imaging.AutoOrientation(true))
|
||||
if p.Filename == "" {
|
||||
p.Filename = fmt.Sprintf(
|
||||
"%s_%s",
|
||||
@ -179,12 +184,6 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
|
||||
)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, &pongo2.Error{
|
||||
Sender: "filter:image_resize",
|
||||
OrigError: fmt.Errorf("could not open image '%s': %s", imgSource, err),
|
||||
}
|
||||
}
|
||||
|
||||
imgTarget := ResolveOutputPath(p.Filename)
|
||||
|
||||
@ -192,6 +191,17 @@ func ImageProcessFilter(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *
|
||||
Log.Noticef("skipped processing image from %s to %s, file already exists", imgSource, imgTarget)
|
||||
} else {
|
||||
Log.Noticef("processing image from %s to %s", imgSource, imgTarget)
|
||||
if strings.HasPrefix(imgSource, "http://") || strings.HasPrefix(imgSource, "https://") {
|
||||
// webrequest before finding target filename, because of file format in filename
|
||||
} else {
|
||||
img, err = imaging.Open(imgSource, imaging.AutoOrientation(true))
|
||||
if err != nil {
|
||||
return nil, &pongo2.Error{
|
||||
Sender: "filter:image_resize",
|
||||
OrigError: fmt.Errorf("could not open image '%s': %s", imgSource, err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch p.Process {
|
||||
case "resize":
|
||||
|
Loading…
Reference in New Issue
Block a user