Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 42 additions & 17 deletions packages/common/src/config/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3046,11 +3046,16 @@
"unit": "mm"
},
"rules": {
"minHeadHeight": 0.7446808510638298,
"minHeadOffset": 0.0851063829787234
"minHeadHeight": 0.6808510638297872,
"maxHeadHeight": 0.7659574468085106,
"minHeadOffset": 0.0851063829787234,
"maxHeadOffset": 0.1276595744680851,
"minChinOffset": 0.14893617021276595,
"maxChinOffset": 0.19148936170212766,
"maxCenterOffset": 0.031914893617021274
},
"background": "#d3d3d3",
"comment": "The size (width x height) of Finland Passport photo is 36x47 (in mm) or 3.6x4.7 (in cm) or 1.42x1.85 (in inches) or 850x1110 (in pixels at 600DPI)\nCare should be taken to position the face within the photo as per the following requirements for Finland Passport photo. The minimum head height should be 35mm. Top of the head should be at a minimum of 4mm from the top. \nPhoto for Finland Passport should be taken in a Light Grey background as shown in this example. \nYou should print Finland Passport photo on Glossy/Matte type of photo paper"
"comment": "The size (width x height) of Finland Passport photo is 36x47 mm.\nHead height from crown to chin (excluding hair) must be 32-36 mm. Space above the crown must be 4-6 mm and below the chin 7-9 mm. The centre line of the face may be at most 1.5 mm from the centre line of the photo.\nThe background should be plain, light and neutral; light grey is best.\nSource: Poliisin passikuvaohje (Finnish Police photo guide, 2020), https://poliisi.fi/documents/25235045/31329600/Poliisin-passikuvaohje-2020-FI.pdf"
},
{
"name": "finland_visa",
Expand All @@ -3066,11 +3071,16 @@
"unit": "mm"
},
"rules": {
"minHeadHeight": 0.7446808510638298,
"minHeadOffset": 0.0851063829787234
"minHeadHeight": 0.6808510638297872,
"maxHeadHeight": 0.7659574468085106,
"minHeadOffset": 0.0851063829787234,
"maxHeadOffset": 0.1276595744680851,
"minChinOffset": 0.14893617021276595,
"maxChinOffset": 0.19148936170212766,
"maxCenterOffset": 0.031914893617021274
},
"background": "#d3d3d3",
"comment": "The size (width x height) of Finland Visa photo is 36x47 (in mm) or 3.6x4.7 (in cm) or 1.42x1.85 (in inches) or 850x1110 (in pixels at 600DPI)\nCare should be taken to position the face within the photo as per the following requirements for Finland Visa photo. The minimum head height should be 35mm. Top of the head should be at a minimum of 4mm from the top. \nPhoto for Finland Visa should be taken in a Light Grey background as shown in this example. \nYou should print Finland Visa photo on Glossy/Matte type of photo paper"
"comment": "The size (width x height) of Finland Visa photo is 36x47 mm.\nHead height from crown to chin (excluding hair) must be 32-36 mm. Space above the crown must be 4-6 mm and below the chin 7-9 mm. The centre line of the face may be at most 1.5 mm from the centre line of the photo.\nThe background should be plain, light and neutral; light grey is best.\nSource: Poliisin passikuvaohje (Finnish Police photo guide, 2020), https://poliisi.fi/documents/25235045/31329600/Poliisin-passikuvaohje-2020-FI.pdf"
},
{
"name": "finland_passport_online",
Expand All @@ -3080,18 +3090,23 @@
"zone": "FI",
"flag": "🇫🇮",
"dimension": {
"dpi": 600,
"dpi": 352.8,
"width": 500,
"height": 653,
"unit": "mm"
},
"rules": {
"size": 250,
"minHeadHeight": 0.7457886676875957,
"minHeadOffset": 0.08575803981623277
"minHeadHeight": 0.6814701378254211,
"maxHeadHeight": 0.7656967840735069,
"minHeadOffset": 0.08575803981623277,
"maxHeadOffset": 0.12863705972434916,
"minChinOffset": 0.14701378254211334,
"maxChinOffset": 0.18989280245022971,
"maxCenterOffset": 0.03215926493108729
},
"background": "#d3d3d3",
"comment": "The size (width x height) of Finland Passport online photo is 21.17x27.64 (in mm) or 2.12x2.76 (in cm) or 0.83x1.09 (in inches) or 500x653 (in pixels at 600DPI)\nCare should be taken to position the face within the photo as per the following requirements for Finland Passport online photo. The minimum head height should be 487pixel. Top of the head should be at a minimum of 56pixel from the top. \nPhoto for Finland Passport online should be taken in a Light Grey background as shown in this example. \nThe Maximum file size for Finland Passport online should be 250 KB"
"comment": "The Finland Passport online photo must be exactly 500x653 pixels (36x47 mm), JPEG, at most 250 KB.\nHead height from crown to chin (excluding hair) must be 445-500 px. Space above the crown must be 56-84 px and below the chin 96-124 px. The centre line of the face may be at most 21 px from the centre line of the photo.\nThe background should be plain, light and neutral; light grey is best.\nSource: Poliisin passikuvaohje (Finnish Police photo guide, 2020), https://poliisi.fi/documents/25235045/31329600/Poliisin-passikuvaohje-2020-FI.pdf"
},
{
"name": "finland_id_card_online",
Expand All @@ -3101,18 +3116,23 @@
"zone": "FI",
"flag": "🇫🇮",
"dimension": {
"dpi": 600,
"dpi": 352.8,
"width": 500,
"height": 653,
"unit": "mm"
},
"rules": {
"size": 250,
"minHeadHeight": 0.7457886676875957,
"minHeadOffset": 0.08575803981623277
"minHeadHeight": 0.6814701378254211,
"maxHeadHeight": 0.7656967840735069,
"minHeadOffset": 0.08575803981623277,
"maxHeadOffset": 0.12863705972434916,
"minChinOffset": 0.14701378254211334,
"maxChinOffset": 0.18989280245022971,
"maxCenterOffset": 0.03215926493108729
},
"background": "#d3d3d3",
"comment": "The size (width x height) of Finland ID card online photo is 21.17x27.64 (in mm) or 2.12x2.76 (in cm) or 0.83x1.09 (in inches) or 500x653 (in pixels at 600DPI)\nCare should be taken to position the face within the photo as per the following requirements for Finland ID card online photo. The minimum head height should be 487pixel. Top of the head should be at a minimum of 56pixel from the top. \nPhoto for Finland ID card online should be taken in a Light Grey background as shown in this example. \nThe Maximum file size for Finland ID card online should be 250 KB"
"comment": "The Finland ID card online photo must be exactly 500x653 pixels (36x47 mm), JPEG, at most 250 KB.\nHead height from crown to chin (excluding hair) must be 445-500 px. Space above the crown must be 56-84 px and below the chin 96-124 px. The centre line of the face may be at most 21 px from the centre line of the photo.\nThe background should be plain, light and neutral; light grey is best.\nSource: Poliisin passikuvaohje (Finnish Police photo guide, 2020), https://poliisi.fi/documents/25235045/31329600/Poliisin-passikuvaohje-2020-FI.pdf"
},
{
"name": "finland_id_card",
Expand All @@ -3128,11 +3148,16 @@
"unit": "mm"
},
"rules": {
"minHeadHeight": 0.7446808510638298,
"minHeadOffset": 0.0851063829787234
"minHeadHeight": 0.6808510638297872,
"maxHeadHeight": 0.7659574468085106,
"minHeadOffset": 0.0851063829787234,
"maxHeadOffset": 0.1276595744680851,
"minChinOffset": 0.14893617021276595,
"maxChinOffset": 0.19148936170212766,
"maxCenterOffset": 0.031914893617021274
},
"background": "#d3d3d3",
"comment": "The size (width x height) of Finland ID card photo is 36x47 (in mm) or 3.6x4.7 (in cm) or 1.42x1.85 (in inches) or 850x1110 (in pixels at 600DPI)\nCare should be taken to position the face within the photo as per the following requirements for Finland ID card photo. The minimum head height should be 35mm. Top of the head should be at a minimum of 4mm from the top. \nPhoto for Finland ID card should be taken in a Light Grey background as shown in this example. \nYou should print Finland ID card photo on Glossy/Matte type of photo paper"
"comment": "The size (width x height) of Finland ID card photo is 36x47 mm.\nHead height from crown to chin (excluding hair) must be 32-36 mm. Space above the crown must be 4-6 mm and below the chin 7-9 mm. The centre line of the face may be at most 1.5 mm from the centre line of the photo.\nThe background should be plain, light and neutral; light grey is best.\nSource: Poliisin passikuvaohje (Finnish Police photo guide, 2020), https://poliisi.fi/documents/25235045/31329600/Poliisin-passikuvaohje-2020-FI.pdf"
},
{
"name": "france_passport",
Expand Down
14 changes: 14 additions & 0 deletions packages/common/src/config/spec.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,26 @@ describe('spec.json', () => {
'minHeadHeight',
'maxHeadHeight',
'minHeadOffset',
'maxHeadOffset',
'minChinOffset',
'maxChinOffset',
'maxCenterOffset',
] as const) {
const value = rules[key]
if (value !== undefined && !(value > 0 && value <= 1)) {
bad.push(`${spec.name}.${key}=${value}`)
}
}
for (const [min, max] of [
['minHeadOffset', 'maxHeadOffset'],
['minChinOffset', 'maxChinOffset'],
] as const) {
const lo = rules[min]
const hi = rules[max]
if (lo !== undefined && hi !== undefined && lo > hi) {
bad.push(`${spec.name}: ${min} > ${max}`)
}
}
const { minHeadHeight, maxHeadHeight, minHeadOffset = 0 } = rules
if (
minHeadHeight !== undefined &&
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"printSheet": "4x6-duim-vel",
"printSheetSaved": "4x6-vel: {count} x {title} ({size}), {columns}x{rows} teen {dpi} DPI.",
"guides": "Riglyne",
"backgroundRemoval": "Agtergrondverwydering",
"backgroundRemovalHint": "Onder 100% skyn van die oorspronklike agtergrond deur, wat minder verwerk lyk. Owerhede kan dit steeds as 'n geredigeerde foto beskou.",
"filter": "Filter",
"filterOriginal": "Oorspronklik",
"filterGrayscale": "S&W",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "ورقة 4x6 بوصة",
"printSheetSaved": "ورقة 4x6: {count} × {title} ({size})، {columns}x{rows} بدقة {dpi} DPI.",
"guides": "خطوط إرشادية",
"backgroundRemoval": "إزالة الخلفية",
"backgroundRemovalHint": "أقل من 100% يظهر جزء من الخلفية الأصلية، فتبدو الصورة أقل معالجة. قد تعتبرها الجهات الرسمية صورة معدّلة مع ذلك.",
"filter": "فلتر",
"filterOriginal": "الأصلي",
"filterGrayscale": "أبيض وأسود",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "4x6-Zoll-Bogen",
"printSheetSaved": "4x6-Bogen: {count} x {title} ({size}), {columns}x{rows} bei {dpi} DPI.",
"guides": "Hilfslinien",
"backgroundRemoval": "Hintergrundentfernung",
"backgroundRemovalHint": "Unter 100 % scheint etwas vom ursprünglichen Hintergrund durch, das wirkt weniger bearbeitet. Behörden können es trotzdem als bearbeitetes Foto werten.",
"filter": "Filter",
"filterOriginal": "Original",
"filterGrayscale": "S/W",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "4x6 inch sheet",
"printSheetSaved": "4x6 sheet: {count} x {title} ({size}), {columns}x{rows} at {dpi} DPI.",
"guides": "Guides",
"backgroundRemoval": "Background removal",
"backgroundRemovalHint": "Below 100% some of the original background shows through, which looks less processed. Authorities may still count it as an edited photo.",
"filter": "Filter",
"filterOriginal": "Original",
"filterGrayscale": "B&W",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "Planche 4x6 pouces",
"printSheetSaved": "Planche 4x6 : {count} x {title} ({size}), {columns}x{rows} à {dpi} DPI.",
"guides": "Repères",
"backgroundRemoval": "Suppression de l'arrière-plan",
"backgroundRemovalHint": "En dessous de 100 %, une partie de l'arrière-plan d'origine reste visible, ce qui paraît moins retouché. Les autorités peuvent quand même la considérer comme une photo modifiée.",
"filter": "Filtre",
"filterOriginal": "Original",
"filterGrayscale": "N&B",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "4x6インチ台紙",
"printSheetSaved": "4x6台紙:{title}({size})× {count}枚、{columns}x{rows}、{dpi} DPI。",
"guides": "ガイド",
"backgroundRemoval": "背景除去",
"backgroundRemovalHint": "100% 未満では元の背景が少し透けて、加工感が減ります。それでも当局は編集済みの写真とみなす場合があります。",
"filter": "フィルター",
"filterOriginal": "オリジナル",
"filterGrayscale": "白黒",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "4x6인치 인화지",
"printSheetSaved": "4x6 인화지: {title}({size}) {count}장, {columns}x{rows}, {dpi} DPI.",
"guides": "안내선",
"backgroundRemoval": "배경 제거",
"backgroundRemovalHint": "100% 미만이면 원래 배경이 일부 비쳐 덜 가공된 느낌이 납니다. 그래도 기관에서는 편집된 사진으로 볼 수 있습니다.",
"filter": "필터",
"filterOriginal": "원본",
"filterGrayscale": "흑백",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "Folha de 4x6 polegadas",
"printSheetSaved": "Folha 4x6: {count} x {title} ({size}), {columns}x{rows} a {dpi} DPI.",
"guides": "Guias",
"backgroundRemoval": "Remoção do fundo",
"backgroundRemovalHint": "Abaixo de 100%, parte do fundo original aparece, o que parece menos processado. As autoridades ainda podem considerá-la uma foto editada.",
"filter": "Filtro",
"filterOriginal": "Original",
"filterGrayscale": "P&B",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "Лист 4x6 дюйма",
"printSheetSaved": "Лист 4x6: {count} x {title} ({size}), {columns}x{rows}, {dpi} DPI.",
"guides": "Направляющие",
"backgroundRemoval": "Удаление фона",
"backgroundRemovalHint": "Ниже 100% часть исходного фона просвечивает, и фото выглядит менее обработанным. Органы всё равно могут счесть его отредактированным.",
"filter": "Фильтр",
"filterOriginal": "Оригинал",
"filterGrayscale": "Ч/Б",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "แผ่นขนาด 4x6 นิ้ว",
"printSheetSaved": "แผ่น 4x6: {title} ({size}) {count} รูป, {columns}x{rows} ที่ {dpi} DPI",
"guides": "เส้นนำ",
"backgroundRemoval": "การลบพื้นหลัง",
"backgroundRemovalHint": "ต่ำกว่า 100% พื้นหลังเดิมจะปรากฏบางส่วน ทำให้ดูผ่านการแต่งน้อยลง แต่หน่วยงานอาจยังถือว่าเป็นภาพที่แก้ไขแล้ว",
"filter": "ฟิลเตอร์",
"filterOriginal": "ต้นฉบับ",
"filterGrayscale": "ขาวดำ",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "4x6 inç sayfa",
"printSheetSaved": "4x6 sayfa: {count} x {title} ({size}), {columns}x{rows}, {dpi} DPI.",
"guides": "Kılavuzlar",
"backgroundRemoval": "Arka plan kaldırma",
"backgroundRemovalHint": "%100'ün altında orijinal arka planın bir kısmı görünür ve fotoğraf daha az işlenmiş görünür. Yetkililer yine de bunu düzenlenmiş fotoğraf sayabilir.",
"filter": "Filtre",
"filterOriginal": "Orijinal",
"filterGrayscale": "S/B",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "trang 4x6 inch",
"printSheetSaved": "Trang 4x6: {count} x {title} ({size}), {columns}x{rows} ở {dpi} DPI.",
"guides": "đường gióng",
"backgroundRemoval": "Xóa phông nền",
"backgroundRemovalHint": "Dưới 100%, một phần phông nền gốc sẽ hiện ra, trông ít qua xử lý hơn. Cơ quan chức năng vẫn có thể coi đây là ảnh đã chỉnh sửa.",
"filter": "bộ lọc",
"filterOriginal": "gốc",
"filterGrayscale": "đen trắng",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "4x6 吋排版相片",
"printSheetSaved": "4x6 排版:{count} 張 {title}({size}),{columns}x{rows},{dpi} DPI。",
"guides": "參考線",
"backgroundRemoval": "背景移除",
"backgroundRemovalHint": "低於 100% 時會透出部分原有背景,看起來較少處理痕跡。但有關機構仍可能視為經編輯的相片。",
"filter": "濾鏡",
"filterOriginal": "原圖",
"filterGrayscale": "黑白",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"printSheet": "4x6 吋排版相片",
"printSheetSaved": "4x6 排版:{count} 張 {title}({size}),{columns}x{rows},{dpi} DPI。",
"guides": "參考線",
"backgroundRemoval": "背景移除",
"backgroundRemovalHint": "低於 100% 時會透出部分原始背景,看起來較少處理痕跡。但相關機關仍可能視為經過編輯的照片。",
"filter": "濾鏡",
"filterOriginal": "原圖",
"filterGrayscale": "黑白",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"printSheetTooLarge": "该规格尺寸过大,无法在4x6寸纸张上排版。",
"printSheetFailed": "生成排版照片失败。",
"guides": "参考线",
"backgroundRemoval": "背景移除",
"backgroundRemovalHint": "低于 100% 时会透出部分原始背景,看起来处理痕迹更少。但相关机构仍可能视为编辑过的照片。",
"filter": "滤镜",
"filterOriginal": "原图",
"filterGrayscale": "黑白",
Expand Down
21 changes: 17 additions & 4 deletions packages/common/src/pages/cropper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
useSegementStore,
useSelectedSpec,
} from '../../stores'
import { cropIDPhoto } from '../../utils'
import { cropIDPhoto, cropMatchingOriginal } from '../../utils'
import {
CloseButton,
ConfigContext,
Expand Down Expand Up @@ -109,15 +109,28 @@ export default function Cropper() {
!result
const sourceImage = useOriginal ? image : result

const idPhoto = await cropIDPhoto({
image: sourceImage,
const cropOptions = {
area: croppedArea,
rotation,
flipHorizontal,
flipVertical,
resolution: currentSpec.dimension,
}
const idPhoto = await cropIDPhoto({
...cropOptions,
image: sourceImage,
})
useAppStore.getState().retouch(idPhoto)
// The same crop of the original lets retouching blend some of the
// original background back in. The area was measured on the cutout,
// which may not share the original's resolution.
const original = useOriginal
? undefined
: await cropMatchingOriginal({
...cropOptions,
image,
cutout: result,
})
useAppStore.getState().retouch(idPhoto, original)
} catch (error) {
enqueueSnackbar(
intl.formatMessage({
Expand Down
Loading