Documentation
¶
Index ¶
- Constants
- func AddWatermark(img image.Image, s PhotoSettings, opacity float64) (image.Image, error)
- func ApplyOrientation(img image.Image, x *exiflib.Exif) image.Image
- func CollectFiles(args []string) ([]string, error)
- func DecodeImage(path string) (image.Image, error)
- func IsSupportedExt(path string) bool
- func OutputPath(inputPath, outDir string) string
- func ProcessFile(inputPath, outDir string, opacity float64) error
- func ResizeForWhatsApp(img image.Image) image.Image
- type PhotoSettings
Constants ¶
const ( // MaxWhatsAppDim is the maximum pixel dimension (longest side) for WhatsApp HD output. MaxWhatsAppDim = 2560 // JPEGQuality is the JPEG encoding quality used for all output files. JPEGQuality = 92 )
Variables ¶
This section is empty.
Functions ¶
func AddWatermark ¶
AddWatermark stamps a translucent pill-shaped overlay containing the camera settings from s onto img. opacity controls the background pill transparency (0 = invisible, 1 = fully opaque). When s contains no data the image is returned unchanged and no error is raised.
func ApplyOrientation ¶
ApplyOrientation rotates img to its upright position according to the EXIF orientation tag. It is a no-op when x is nil or the orientation tag is absent or has value 1 (normal).
func CollectFiles ¶
CollectFiles expands the given paths (files or directories) into a flat list of supported image files. Directories are walked recursively. Unsupported files are skipped with a message to stderr. An error is returned only when a path cannot be stat'd.
func DecodeImage ¶
DecodeImage decodes a JPEG, PNG, or ARW file at path into an image.Image. ARW files are attempted via three fallback strategies: embedded JPEG extraction, dcraw, then ImageMagick. An error is returned only when all strategies fail or the file cannot be opened.
func IsSupportedExt ¶
IsSupportedExt reports whether path has a supported image extension (arw, jpg, jpeg, or png, case-insensitive).
func OutputPath ¶
OutputPath returns the output file path for inputPath placed under outDir, replacing the original extension with .jpg.
func ProcessFile ¶
ProcessFile is the single entry point for processing one image file. It reads EXIF metadata, decodes the image, applies orientation correction, resizes it to WhatsApp HD dimensions, stamps the watermark, and writes a JPEG to outDir.
Types ¶
type PhotoSettings ¶
type PhotoSettings struct {
Aperture string
ShutterSpeed string
ISO string
FocalLength string
CameraModel string
}
PhotoSettings holds the EXIF camera-settings fields extracted from a photo. Fields that are absent in the EXIF data are left as empty strings.
func ReadEXIF ¶
func ReadEXIF(path string) (PhotoSettings, *exiflib.Exif)
ReadEXIF reads EXIF metadata from the file at path and returns the camera settings and the raw Exif value (used for orientation correction). On any read or decode failure an empty PhotoSettings and nil Exif are returned so the caller can still process the image without metadata.