diff --git a/internal/imgcache/imgcache.go b/internal/imgcache/imgcache.go index 8a55723..7307dab 100644 --- a/internal/imgcache/imgcache.go +++ b/internal/imgcache/imgcache.go @@ -187,6 +187,12 @@ type ProcessResult struct { Width int // Height is the output image height Height int + // InputWidth is the original image width before processing + InputWidth int + // InputHeight is the original image height before processing + InputHeight int + // InputFormat is the detected input format (e.g., "jpeg", "png") + InputFormat string } // Storage handles persistent storage of cached content diff --git a/internal/imgcache/processor.go b/internal/imgcache/processor.go index cf629ad..caca8f3 100644 --- a/internal/imgcache/processor.go +++ b/internal/imgcache/processor.go @@ -93,6 +93,9 @@ func (p *ImageProcessor) Process( ContentType: ImageFormatToMIME(outputFormat), Width: finalBounds.Dx(), Height: finalBounds.Dy(), + InputWidth: origWidth, + InputHeight: origHeight, + InputFormat: format, }, nil } diff --git a/internal/imgcache/service.go b/internal/imgcache/service.go index a5d712e..3328610 100644 --- a/internal/imgcache/service.go +++ b/internal/imgcache/service.go @@ -162,6 +162,22 @@ func (s *Service) fetchAndProcess(ctx context.Context, req *ImageRequest) (*Imag return nil, fmt.Errorf("image processing failed: %w", err) } + // Log conversion details + inputSize := int64(len(sourceData)) + outputSize := processResult.ContentLength + sizePercent := float64(outputSize) / float64(inputSize) * 100.0 //nolint:mnd // percentage calculation + + s.log.Info("image converted", + "file", req.SourcePath, + "input_format", processResult.InputFormat, + "output_format", req.Format, + "input_bytes", inputSize, + "output_bytes", outputSize, + "input_dimensions", fmt.Sprintf("%dx%d", processResult.InputWidth, processResult.InputHeight), + "output_dimensions", fmt.Sprintf("%dx%d", processResult.Width, processResult.Height), + "size_ratio", fmt.Sprintf("%.1f%%", sizePercent), + ) + // Store output content to cache metaID, err := s.cache.GetSourceMetadataID(ctx, req) if err != nil {