<commit_before>(ns iwaswhere-web.img-route
  "Functions for serving images."
  (:require [compojure.core :refer [GET]]
            [iwaswhere-web.files :as f]
            [clojure.java.io :as io]
            [image-resizer.format :refer :all]
            [image-resizer.resize :refer :all]
            [image-resizer.scale-methods :refer :all]
            [image-resizer.rotate :refer :all]
            [iwaswhere-web.imports :as i]
            [clojure.string :as s]))

(def img-resized-route
  (GET "/photos2/:filename" [filename :as r]
    (let [filename (str f/data-path "/images/" filename)
          file (io/file filename)
          exif (i/extract-exif file)
          orientation (get exif "Orientation")
          rotate-fn (cond (s/includes? orientation "(Rotate 90 CW)")
                          (rotate-270-counter-clockwise-fn)
                          (s/includes? orientation "(Rotate 180)")
                          (rotate-180-counter-clockwise-fn)
                          (s/includes? orientation "(Rotate 270 CW)")
                          (rotate-90-counter-clockwise-fn)<commit_msg>fix image resize bug<commit_after>(ns iwaswhere-web.img-route
  "Functions for serving images."
  (:require [compojure.core :refer [GET]]
            [iwaswhere-web.files :as f]
            [clojure.java.io :as io]
            [image-resizer.format :refer :all]
            [image-resizer.resize :refer :all]
            [image-resizer.scale-methods :refer :all]
            [image-resizer.rotate :refer :all]
            [iwaswhere-web.imports :as i]
            [clojure.string :as s]))

(def img-resized-route
  (GET "/photos2/:filename" [filename :as r]
    (let [filename (str f/data-path "/images/" filename)
          file (io/file filename)
          exif (i/extract-exif file)
          orientation (get exif "Orientation" "")
          rotate-fn (cond (s/includes? orientation "(Rotate 90 CW)")
                          (rotate-270-counter-clockwise-fn)
                          (s/includes? orientation "(Rotate 180)")
                          (rotate-180-counter-clockwise-fn)
                          (s/includes? orientation "(Rotate 270 CW)")
                          (rotate-90-counter-clockwise-fn)
{'fraction_non_alphanumeric': 0.1273542600896861, 'fraction_numerical': 0.015246636771300448, 'mean_word_length': 1.7714285714285714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2395909', 'n_tokens_mistral': 698, 'n_tokens_neox': 667, 'n_words': 154}