@walkhi/code-relax 0.1.0-beta.3 → 0.1.0-beta.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (837) hide show
  1. package/README.md +83 -71
  2. package/dist/bin/cleanup-accounts.mjs +63 -0
  3. package/dist/bin/codex-remote.mjs +296 -184
  4. package/dist/bin/manage-relay-admin.mjs +20 -0
  5. package/dist/bin/migrate-relay-db.mjs +109 -0
  6. package/dist/bin/publish-android-release.mjs +62 -0
  7. package/dist/bin/self-relay-admin.mjs +8 -0
  8. package/dist/bin/self-relay-demo.mjs +2 -2
  9. package/dist/bin/self-relay-server.mjs +43 -30
  10. package/dist/build-platform.json +1 -0
  11. package/dist/get-shared-service-url.ps1 +6 -6
  12. package/dist/shared/app-server-events.cjs +368 -238
  13. package/dist/shared/code-browser.cjs +159 -0
  14. package/dist/shared/file-changes.cjs +31 -0
  15. package/dist/shared/file-citations.cjs +117 -0
  16. package/dist/shared/file-mentions.cjs +92 -0
  17. package/dist/shared/message-delivery.cjs +54 -0
  18. package/dist/shared/p2p-data-channel.cjs +22 -0
  19. package/dist/shared/p2p-file-channel.cjs +74 -0
  20. package/dist/shared/plan-pricing.cjs +32 -0
  21. package/dist/shared/question-attention.cjs +40 -0
  22. package/dist/shared/server-requests.cjs +157 -5
  23. package/dist/shared/service-endpoints.cjs +21 -0
  24. package/dist/shared/timeline-sync.cjs +111 -5
  25. package/dist/skills/code-relax/SKILL.md +13 -8
  26. package/dist/src/archived-threads.mjs +22 -0
  27. package/dist/src/bounded-process-log.mjs +63 -0
  28. package/dist/src/celsius-client.mjs +107 -0
  29. package/dist/src/code-browser.mjs +100 -0
  30. package/dist/src/desktop-launcher.mjs +33 -38
  31. package/dist/src/dots-approval-timeline.mjs +99 -0
  32. package/dist/src/dots-avatar.mjs +42 -0
  33. package/dist/src/dots-chat-projection.mjs +50 -0
  34. package/dist/src/dots-chat-server.mjs +461 -0
  35. package/dist/src/dots-message-images.mjs +319 -0
  36. package/dist/src/dots-profile.mjs +77 -0
  37. package/dist/src/dots-room-activity.mjs +94 -0
  38. package/dist/src/dots-room-client.mjs +135 -0
  39. package/dist/src/dots-room-projection.mjs +94 -0
  40. package/dist/src/dots-schedules.mjs +66 -0
  41. package/dist/src/dots-summary-tasks.mjs +32 -0
  42. package/dist/src/dots-task-catalog.mjs +430 -0
  43. package/dist/src/dots-task-files.mjs +52 -0
  44. package/dist/src/file-transfer-range.mjs +22 -0
  45. package/dist/src/file-upload-session.mjs +130 -0
  46. package/dist/src/hosted-history-app-server.mjs +103 -0
  47. package/dist/src/hosted-history-cache.mjs +113 -0
  48. package/dist/src/lan-socket-server.mjs +240 -84
  49. package/dist/src/managed-app-server.mjs +53 -16
  50. package/dist/src/message-images.mjs +0 -18
  51. package/dist/src/message-upload-files.mjs +74 -0
  52. package/dist/src/onboarding.mjs +10 -29
  53. package/dist/src/plan-pricing.mjs +47 -0
  54. package/dist/src/platform/README.md +2 -2
  55. package/dist/src/platform/codex-protocol.mjs +46 -0
  56. package/dist/src/platform/codex-runtime.mjs +3 -0
  57. package/dist/src/platform/credential-store.mjs +3 -0
  58. package/dist/src/platform/desktop-host.mjs +3 -0
  59. package/dist/src/platform/desktop-project-registration.mjs +3 -0
  60. package/dist/src/platform/desktop-project-store.mjs +208 -0
  61. package/dist/src/platform/file-opener.mjs +9 -0
  62. package/dist/src/platform/linux/codex-runtime.mjs +56 -0
  63. package/dist/src/platform/linux/credential-store.mjs +28 -0
  64. package/dist/src/platform/linux/desktop-host.mjs +83 -0
  65. package/dist/src/platform/linux/desktop-installation.mjs +36 -0
  66. package/dist/src/platform/linux/desktop-project-registration.mjs +11 -0
  67. package/dist/src/platform/linux/network-info.mjs +11 -0
  68. package/dist/src/platform/linux/process.mjs +42 -0
  69. package/dist/src/platform/linux/project-locations.mjs +17 -0
  70. package/dist/src/platform/linux/resident-startup.mjs +52 -0
  71. package/dist/src/platform/linux/retained-runtime.mjs +76 -0
  72. package/dist/src/platform/linux/service-host.mjs +18 -0
  73. package/dist/src/platform/linux/system.mjs +49 -0
  74. package/dist/src/platform/linux/user-environment.mjs +7 -0
  75. package/dist/src/platform/macos/codex-runtime.mjs +125 -0
  76. package/dist/src/platform/macos/credential-store.mjs +10 -0
  77. package/dist/src/platform/macos/desktop-host.mjs +82 -0
  78. package/dist/src/platform/macos/desktop-project-registration.mjs +11 -0
  79. package/dist/src/platform/macos/network-info.mjs +8 -0
  80. package/dist/src/platform/macos/project-locations.mjs +8 -0
  81. package/dist/src/platform/macos/resident-startup.mjs +84 -0
  82. package/dist/src/platform/macos/retained-runtime.mjs +127 -0
  83. package/dist/src/platform/macos/service-host.mjs +18 -0
  84. package/dist/src/platform/macos/system.mjs +29 -0
  85. package/dist/src/platform/macos/user-environment.mjs +7 -0
  86. package/dist/src/platform/native-package.mjs +58 -0
  87. package/dist/src/platform/network-info.mjs +3 -0
  88. package/dist/src/platform/path-identity.mjs +5 -0
  89. package/dist/src/platform/posix/network-candidates.mjs +23 -0
  90. package/dist/src/platform/posix/runtime-paths.mjs +25 -0
  91. package/dist/src/platform/project-locations.mjs +3 -0
  92. package/dist/src/platform/runtime-paths.mjs +8 -0
  93. package/dist/src/platform/select.mjs +5 -0
  94. package/dist/src/platform/service-host.mjs +3 -0
  95. package/dist/src/platform/user-environment.mjs +3 -0
  96. package/dist/src/platform/windows/activate-desktop.ps1 +48 -0
  97. package/dist/src/platform/windows/codex-runtime.mjs +215 -0
  98. package/dist/src/platform/windows/credential-store.mjs +27 -27
  99. package/dist/src/platform/windows/credential-store.ps1 +49 -49
  100. package/dist/src/platform/windows/desktop-helper.mjs +179 -0
  101. package/dist/src/platform/windows/desktop-host.mjs +43 -23
  102. package/dist/src/platform/windows/desktop-info.ps1 +14 -16
  103. package/dist/src/platform/windows/desktop-project-registration.mjs +4 -0
  104. package/dist/src/platform/windows/desktop-runtime.ps1 +10 -0
  105. package/dist/src/platform/windows/desktop-shortcuts.ps1 +21 -28
  106. package/dist/src/platform/windows/dots-profile.mjs +49 -0
  107. package/dist/src/platform/windows/launch-worker.mjs +17 -18
  108. package/dist/src/platform/windows/project-locations.mjs +16 -0
  109. package/dist/src/platform/windows/resident-start.js +20 -0
  110. package/dist/src/platform/windows/resident-startup.ps1 +76 -20
  111. package/dist/src/platform/windows/rustdesk-video-probe.mjs +168 -0
  112. package/dist/src/platform/windows/service-host.mjs +24 -36
  113. package/dist/src/platform/windows/stop-desktop.ps1 +7 -4
  114. package/dist/src/platform/windows/user-environment.mjs +1 -1
  115. package/dist/src/project-archive.mjs +30 -0
  116. package/dist/src/project-create.mjs +121 -0
  117. package/dist/src/project-management.mjs +59 -0
  118. package/dist/src/project-remove.mjs +55 -0
  119. package/dist/src/project-update.mjs +56 -0
  120. package/dist/src/runtime-discovery.mjs +47 -0
  121. package/dist/src/self-relay/account-cleanup.mjs +30 -0
  122. package/dist/src/self-relay/account-connections.mjs +52 -0
  123. package/dist/src/self-relay/admin-cloud.mjs +101 -0
  124. package/dist/src/self-relay/admin-page.mjs +80 -0
  125. package/dist/src/self-relay/admin-server.mjs +74 -0
  126. package/dist/src/self-relay/admin-state.mjs +85 -19
  127. package/dist/src/self-relay/admin-style.mjs +14 -0
  128. package/dist/src/self-relay/android-releases.mjs +61 -0
  129. package/dist/src/self-relay/client.mjs +45 -45
  130. package/dist/src/self-relay/connector.mjs +421 -144
  131. package/dist/src/self-relay/demo.mjs +34 -35
  132. package/dist/src/self-relay/device-info.mjs +27 -0
  133. package/dist/src/self-relay/device-store.mjs +10 -2
  134. package/dist/src/self-relay/diagnostics.mjs +54 -0
  135. package/dist/src/self-relay/email-accounts.mjs +183 -0
  136. package/dist/src/self-relay/file-wire.mjs +13 -0
  137. package/dist/src/self-relay/lan-authorizations.mjs +44 -2
  138. package/dist/src/self-relay/lifecycle.mjs +256 -273
  139. package/dist/src/self-relay/long-pairing.mjs +40 -0
  140. package/dist/src/self-relay/mysql-state.mjs +118 -0
  141. package/dist/src/self-relay/p2p-probe.mjs +41 -5
  142. package/dist/src/self-relay/privacy-page.mjs +26 -0
  143. package/dist/src/self-relay/public-releases.mjs +34 -0
  144. package/dist/src/self-relay/rtc-file-bridge.mjs +41 -0
  145. package/dist/src/self-relay/server.mjs +655 -115
  146. package/dist/src/self-relay/usage-daily.mjs +55 -0
  147. package/dist/src/self-relay/usage-meter.mjs +141 -0
  148. package/dist/src/server.mjs +1486 -1793
  149. package/dist/src/service-control.mjs +17 -7
  150. package/dist/src/service-doctor.mjs +80 -33
  151. package/dist/src/service-health.mjs +2 -2
  152. package/dist/src/service-install.mjs +85 -85
  153. package/dist/src/service-lifecycle.mjs +116 -108
  154. package/dist/src/service-restart.mjs +43 -10
  155. package/dist/src/shared-app-server.mjs +507 -404
  156. package/dist/src/shared-catalog.mjs +95 -13
  157. package/dist/src/shared-recovery.mjs +15 -11
  158. package/dist/src/shared-thread-stream.mjs +147 -63
  159. package/dist/src/skill-install.mjs +0 -13
  160. package/dist/src/turn-model-history.mjs +47 -0
  161. package/dist/src/usage-reset.mjs +17 -0
  162. package/dist/src/workstation-downloads.mjs +120 -0
  163. package/package.json +35 -37
  164. package/tools/postinstall.mjs +30 -21
  165. package/dist/src/app-server-client.mjs +0 -468
  166. package/dist/src/app-server-tasks.mjs +0 -358
  167. package/dist/src/debug-ui.mjs +0 -131
  168. package/dist/src/platform/windows/desktop-monitor.mjs +0 -34
  169. package/dist/src/platform/windows/desktop-shortcut-run.ps1 +0 -5
  170. package/dist/src/platform/windows/desktop-tools.mjs +0 -48
  171. package/dist/src/thread-catalog.mjs +0 -47
  172. package/dist/tools/find-desktop-pipe.mjs +0 -10
  173. package/dist/web/activity-view.js +0 -283
  174. package/dist/web/approval-ui.js +0 -188
  175. package/dist/web/capabilities.js +0 -57
  176. package/dist/web/chat-transport.js +0 -202
  177. package/dist/web/chat.css +0 -782
  178. package/dist/web/chat.js +0 -3830
  179. package/dist/web/client-platform.js +0 -11
  180. package/dist/web/community-view.js +0 -20
  181. package/dist/web/community.css +0 -77
  182. package/dist/web/community.html +0 -37
  183. package/dist/web/composer-controller.js +0 -101
  184. package/dist/web/conversation-controller.js +0 -99
  185. package/dist/web/disclosure-state-controller.js +0 -95
  186. package/dist/web/draft-controller.js +0 -103
  187. package/dist/web/harmony-platform.js +0 -52
  188. package/dist/web/highlight-powershell.min.js +0 -39
  189. package/dist/web/highlight.min.js +0 -1262
  190. package/dist/web/history-cache.js +0 -240
  191. package/dist/web/history-controller.js +0 -167
  192. package/dist/web/index.html +0 -325
  193. package/dist/web/lan-session.js +0 -122
  194. package/dist/web/link-action-controller.js +0 -212
  195. package/dist/web/message-send-controller.js +0 -177
  196. package/dist/web/message-view.js +0 -98
  197. package/dist/web/p2p-data-channel.js +0 -50
  198. package/dist/web/p2p-diagnostics.js +0 -28
  199. package/dist/web/p2p-probe.js +0 -123
  200. package/dist/web/page-resume.js +0 -28
  201. package/dist/web/pending-message-store.js +0 -108
  202. package/dist/web/queue-controller.js +0 -82
  203. package/dist/web/resources.json +0 -1
  204. package/dist/web/self-relay-session.js +0 -129
  205. package/dist/web/server-requests.js +0 -67
  206. package/dist/web/station-connection-controller.js +0 -75
  207. package/dist/web/task-list-view.js +0 -296
  208. package/dist/web/thread-attention-controller.js +0 -124
  209. package/dist/web/thread-context-controller.js +0 -30
  210. package/dist/web/thread-list-controller.js +0 -61
  211. package/dist/web/thread-list-sync.js +0 -86
  212. package/dist/web/thread-title-controller.js +0 -57
  213. package/dist/web/timeline-formatters.js +0 -249
  214. package/dist/web/timeline-reducer.js +0 -81
  215. package/dist/web/timeline-renderer.js +0 -161
  216. package/dist/web/timeline-scroll-controller.js +0 -50
  217. package/dist/web/timeline-sync.js +0 -67
  218. package/dist/web/usage-controller.js +0 -258
  219. package/dist/web/vendor/README.md +0 -14
  220. package/dist/web/vendor/highlight-powershell.min.js +0 -39
  221. package/dist/web/vendor/highlight.LICENSE.txt +0 -29
  222. package/dist/web/vendor/highlight.min.js +0 -1262
  223. package/dist/web/vendor/lucide.LICENSE.txt +0 -17
  224. package/node_modules/@img/colour/LICENSE.md +0 -82
  225. package/node_modules/@img/colour/README.md +0 -15
  226. package/node_modules/@img/colour/color.cjs +0 -1596
  227. package/node_modules/@img/colour/index.cjs +0 -1
  228. package/node_modules/@img/colour/index.d.ts +0 -929
  229. package/node_modules/@img/colour/package.json +0 -58
  230. package/node_modules/@img/sharp-win32-x64/LICENSE +0 -191
  231. package/node_modules/@img/sharp-win32-x64/README.md +0 -59
  232. package/node_modules/@img/sharp-win32-x64/index.cjs +0 -1
  233. package/node_modules/@img/sharp-win32-x64/lib/libvips-42.dll +0 -0
  234. package/node_modules/@img/sharp-win32-x64/lib/libvips-cpp-8.18.6.dll +0 -0
  235. package/node_modules/@img/sharp-win32-x64/lib/sharp-win32-x64-0.35.4.node +0 -0
  236. package/node_modules/@img/sharp-win32-x64/package.json +0 -40
  237. package/node_modules/@img/sharp-win32-x64/versions.json +0 -30
  238. package/node_modules/@node-datachannel/win32-x64-msvc/node_datachannel.node +0 -0
  239. package/node_modules/@node-datachannel/win32-x64-msvc/package.json +0 -20
  240. package/node_modules/ansi-regex/index.d.ts +0 -37
  241. package/node_modules/ansi-regex/index.js +0 -10
  242. package/node_modules/ansi-regex/license +0 -9
  243. package/node_modules/ansi-regex/package.json +0 -55
  244. package/node_modules/ansi-regex/readme.md +0 -78
  245. package/node_modules/ansi-styles/index.d.ts +0 -345
  246. package/node_modules/ansi-styles/index.js +0 -163
  247. package/node_modules/ansi-styles/license +0 -9
  248. package/node_modules/ansi-styles/package.json +0 -56
  249. package/node_modules/ansi-styles/readme.md +0 -152
  250. package/node_modules/camelcase/index.d.ts +0 -63
  251. package/node_modules/camelcase/index.js +0 -76
  252. package/node_modules/camelcase/license +0 -9
  253. package/node_modules/camelcase/package.json +0 -43
  254. package/node_modules/camelcase/readme.md +0 -99
  255. package/node_modules/cliui/CHANGELOG.md +0 -76
  256. package/node_modules/cliui/LICENSE.txt +0 -14
  257. package/node_modules/cliui/README.md +0 -115
  258. package/node_modules/cliui/index.js +0 -354
  259. package/node_modules/cliui/package.json +0 -65
  260. package/node_modules/color-convert/CHANGELOG.md +0 -54
  261. package/node_modules/color-convert/LICENSE +0 -21
  262. package/node_modules/color-convert/README.md +0 -68
  263. package/node_modules/color-convert/conversions.js +0 -839
  264. package/node_modules/color-convert/index.js +0 -81
  265. package/node_modules/color-convert/package.json +0 -48
  266. package/node_modules/color-convert/route.js +0 -97
  267. package/node_modules/color-name/LICENSE +0 -8
  268. package/node_modules/color-name/README.md +0 -11
  269. package/node_modules/color-name/index.js +0 -152
  270. package/node_modules/color-name/package.json +0 -28
  271. package/node_modules/decamelize/index.js +0 -13
  272. package/node_modules/decamelize/license +0 -21
  273. package/node_modules/decamelize/package.json +0 -38
  274. package/node_modules/decamelize/readme.md +0 -48
  275. package/node_modules/detect-libc/LICENSE +0 -201
  276. package/node_modules/detect-libc/README.md +0 -163
  277. package/node_modules/detect-libc/index.d.ts +0 -14
  278. package/node_modules/detect-libc/lib/detect-libc.js +0 -313
  279. package/node_modules/detect-libc/lib/elf.js +0 -39
  280. package/node_modules/detect-libc/lib/filesystem.js +0 -51
  281. package/node_modules/detect-libc/lib/process.js +0 -24
  282. package/node_modules/detect-libc/package.json +0 -44
  283. package/node_modules/dijkstrajs/.travis.yml +0 -4
  284. package/node_modules/dijkstrajs/CONTRIBUTING.md +0 -8
  285. package/node_modules/dijkstrajs/LICENSE.md +0 -19
  286. package/node_modules/dijkstrajs/README.md +0 -18
  287. package/node_modules/dijkstrajs/dijkstra.js +0 -165
  288. package/node_modules/dijkstrajs/package.json +0 -60
  289. package/node_modules/dijkstrajs/test/dijkstra.test.js +0 -96
  290. package/node_modules/emoji-regex/LICENSE-MIT.txt +0 -20
  291. package/node_modules/emoji-regex/README.md +0 -73
  292. package/node_modules/emoji-regex/es2015/index.js +0 -6
  293. package/node_modules/emoji-regex/es2015/text.js +0 -6
  294. package/node_modules/emoji-regex/index.d.ts +0 -23
  295. package/node_modules/emoji-regex/index.js +0 -6
  296. package/node_modules/emoji-regex/package.json +0 -50
  297. package/node_modules/emoji-regex/text.js +0 -6
  298. package/node_modules/find-up/index.d.ts +0 -137
  299. package/node_modules/find-up/index.js +0 -89
  300. package/node_modules/find-up/license +0 -9
  301. package/node_modules/find-up/package.json +0 -53
  302. package/node_modules/find-up/readme.md +0 -156
  303. package/node_modules/get-caller-file/LICENSE.md +0 -6
  304. package/node_modules/get-caller-file/README.md +0 -41
  305. package/node_modules/get-caller-file/index.d.ts +0 -2
  306. package/node_modules/get-caller-file/index.js +0 -22
  307. package/node_modules/get-caller-file/index.js.map +0 -1
  308. package/node_modules/get-caller-file/package.json +0 -42
  309. package/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
  310. package/node_modules/is-fullwidth-code-point/index.js +0 -50
  311. package/node_modules/is-fullwidth-code-point/license +0 -9
  312. package/node_modules/is-fullwidth-code-point/package.json +0 -42
  313. package/node_modules/is-fullwidth-code-point/readme.md +0 -39
  314. package/node_modules/locate-path/index.d.ts +0 -83
  315. package/node_modules/locate-path/index.js +0 -65
  316. package/node_modules/locate-path/license +0 -9
  317. package/node_modules/locate-path/package.json +0 -45
  318. package/node_modules/locate-path/readme.md +0 -122
  319. package/node_modules/node-datachannel/.clang-format +0 -17
  320. package/node_modules/node-datachannel/.editorconfig +0 -12
  321. package/node_modules/node-datachannel/.eslintignore +0 -8
  322. package/node_modules/node-datachannel/.eslintrc.json +0 -27
  323. package/node_modules/node-datachannel/.gitmodules +0 -3
  324. package/node_modules/node-datachannel/.prettierignore +0 -7
  325. package/node_modules/node-datachannel/.prettierrc +0 -13
  326. package/node_modules/node-datachannel/API.md +0 -247
  327. package/node_modules/node-datachannel/BULDING.md +0 -26
  328. package/node_modules/node-datachannel/CMakeLists.txt +0 -153
  329. package/node_modules/node-datachannel/LICENSE +0 -373
  330. package/node_modules/node-datachannel/README.md +0 -129
  331. package/node_modules/node-datachannel/dist/cjs/index.cjs +0 -11
  332. package/node_modules/node-datachannel/dist/cjs/index.cjs.map +0 -1
  333. package/node_modules/node-datachannel/dist/cjs/lib/datachannel-stream.cjs +0 -101
  334. package/node_modules/node-datachannel/dist/cjs/lib/datachannel-stream.cjs.map +0 -1
  335. package/node_modules/node-datachannel/dist/cjs/lib/index.cjs +0 -91
  336. package/node_modules/node-datachannel/dist/cjs/lib/index.cjs.map +0 -1
  337. package/node_modules/node-datachannel/dist/cjs/lib/node-datachannel.cjs +0 -94
  338. package/node_modules/node-datachannel/dist/cjs/lib/node-datachannel.cjs.map +0 -1
  339. package/node_modules/node-datachannel/dist/cjs/lib/websocket-server.cjs +0 -45
  340. package/node_modules/node-datachannel/dist/cjs/lib/websocket-server.cjs.map +0 -1
  341. package/node_modules/node-datachannel/dist/cjs/lib/websocket.cjs +0 -8
  342. package/node_modules/node-datachannel/dist/cjs/lib/websocket.cjs.map +0 -1
  343. package/node_modules/node-datachannel/dist/cjs/polyfill/Events.cjs +0 -86
  344. package/node_modules/node-datachannel/dist/cjs/polyfill/Events.cjs.map +0 -1
  345. package/node_modules/node-datachannel/dist/cjs/polyfill/Exception.cjs +0 -34
  346. package/node_modules/node-datachannel/dist/cjs/polyfill/Exception.cjs.map +0 -1
  347. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCCertificate.cjs +0 -34
  348. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCCertificate.cjs.map +0 -1
  349. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCDataChannel.cjs +0 -214
  350. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCDataChannel.cjs.map +0 -1
  351. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCDtlsTransport.cjs +0 -53
  352. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCDtlsTransport.cjs.map +0 -1
  353. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCError.cjs +0 -83
  354. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCError.cjs.map +0 -1
  355. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCIceCandidate.cjs +0 -132
  356. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCIceCandidate.cjs.map +0 -1
  357. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCIceTransport.cjs +0 -94
  358. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCIceTransport.cjs.map +0 -1
  359. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCPeerConnection.cjs +0 -434
  360. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCPeerConnection.cjs.map +0 -1
  361. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCSctpTransport.cjs +0 -59
  362. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCSctpTransport.cjs.map +0 -1
  363. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCSessionDescription.cjs +0 -45
  364. package/node_modules/node-datachannel/dist/cjs/polyfill/RTCSessionDescription.cjs.map +0 -1
  365. package/node_modules/node-datachannel/dist/cjs/polyfill/index.cjs +0 -42
  366. package/node_modules/node-datachannel/dist/cjs/polyfill/index.cjs.map +0 -1
  367. package/node_modules/node-datachannel/dist/esm/index.mjs +0 -8
  368. package/node_modules/node-datachannel/dist/esm/index.mjs.map +0 -1
  369. package/node_modules/node-datachannel/dist/esm/lib/datachannel-stream.mjs +0 -78
  370. package/node_modules/node-datachannel/dist/esm/lib/datachannel-stream.mjs.map +0 -1
  371. package/node_modules/node-datachannel/dist/esm/lib/index.mjs +0 -64
  372. package/node_modules/node-datachannel/dist/esm/lib/index.mjs.map +0 -1
  373. package/node_modules/node-datachannel/dist/esm/lib/node-datachannel.mjs +0 -78
  374. package/node_modules/node-datachannel/dist/esm/lib/node-datachannel.mjs.map +0 -1
  375. package/node_modules/node-datachannel/dist/esm/lib/websocket-server.mjs +0 -43
  376. package/node_modules/node-datachannel/dist/esm/lib/websocket-server.mjs.map +0 -1
  377. package/node_modules/node-datachannel/dist/esm/lib/websocket.mjs +0 -6
  378. package/node_modules/node-datachannel/dist/esm/lib/websocket.mjs.map +0 -1
  379. package/node_modules/node-datachannel/dist/esm/polyfill/Events.mjs +0 -82
  380. package/node_modules/node-datachannel/dist/esm/polyfill/Events.mjs.map +0 -1
  381. package/node_modules/node-datachannel/dist/esm/polyfill/Exception.mjs +0 -28
  382. package/node_modules/node-datachannel/dist/esm/polyfill/Exception.mjs.map +0 -1
  383. package/node_modules/node-datachannel/dist/esm/polyfill/RTCCertificate.mjs +0 -30
  384. package/node_modules/node-datachannel/dist/esm/polyfill/RTCCertificate.mjs.map +0 -1
  385. package/node_modules/node-datachannel/dist/esm/polyfill/RTCDataChannel.mjs +0 -210
  386. package/node_modules/node-datachannel/dist/esm/polyfill/RTCDataChannel.mjs.map +0 -1
  387. package/node_modules/node-datachannel/dist/esm/polyfill/RTCDtlsTransport.mjs +0 -49
  388. package/node_modules/node-datachannel/dist/esm/polyfill/RTCDtlsTransport.mjs.map +0 -1
  389. package/node_modules/node-datachannel/dist/esm/polyfill/RTCError.mjs +0 -79
  390. package/node_modules/node-datachannel/dist/esm/polyfill/RTCError.mjs.map +0 -1
  391. package/node_modules/node-datachannel/dist/esm/polyfill/RTCIceCandidate.mjs +0 -128
  392. package/node_modules/node-datachannel/dist/esm/polyfill/RTCIceCandidate.mjs.map +0 -1
  393. package/node_modules/node-datachannel/dist/esm/polyfill/RTCIceTransport.mjs +0 -89
  394. package/node_modules/node-datachannel/dist/esm/polyfill/RTCIceTransport.mjs.map +0 -1
  395. package/node_modules/node-datachannel/dist/esm/polyfill/RTCPeerConnection.mjs +0 -430
  396. package/node_modules/node-datachannel/dist/esm/polyfill/RTCPeerConnection.mjs.map +0 -1
  397. package/node_modules/node-datachannel/dist/esm/polyfill/RTCSctpTransport.mjs +0 -55
  398. package/node_modules/node-datachannel/dist/esm/polyfill/RTCSctpTransport.mjs.map +0 -1
  399. package/node_modules/node-datachannel/dist/esm/polyfill/RTCSessionDescription.mjs +0 -41
  400. package/node_modules/node-datachannel/dist/esm/polyfill/RTCSessionDescription.mjs.map +0 -1
  401. package/node_modules/node-datachannel/dist/esm/polyfill/index.mjs +0 -27
  402. package/node_modules/node-datachannel/dist/esm/polyfill/index.mjs.map +0 -1
  403. package/node_modules/node-datachannel/dist/types/lib/datachannel-stream.d.ts +0 -24
  404. package/node_modules/node-datachannel/dist/types/lib/index.d.ts +0 -241
  405. package/node_modules/node-datachannel/dist/types/lib/types.d.ts +0 -119
  406. package/node_modules/node-datachannel/dist/types/lib/websocket-server.d.ts +0 -13
  407. package/node_modules/node-datachannel/dist/types/lib/websocket.d.ts +0 -25
  408. package/node_modules/node-datachannel/dist/types/polyfill/Events.d.ts +0 -15
  409. package/node_modules/node-datachannel/dist/types/polyfill/RTCCertificate.d.ts +0 -9
  410. package/node_modules/node-datachannel/dist/types/polyfill/RTCDataChannel.d.ts +0 -29
  411. package/node_modules/node-datachannel/dist/types/polyfill/RTCDtlsTransport.d.ts +0 -15
  412. package/node_modules/node-datachannel/dist/types/polyfill/RTCError.d.ts +0 -17
  413. package/node_modules/node-datachannel/dist/types/polyfill/RTCIceCandidate.d.ts +0 -21
  414. package/node_modules/node-datachannel/dist/types/polyfill/RTCIceTransport.d.ts +0 -30
  415. package/node_modules/node-datachannel/dist/types/polyfill/RTCPeerConnection.d.ts +0 -64
  416. package/node_modules/node-datachannel/dist/types/polyfill/RTCSctpTransport.d.ts +0 -15
  417. package/node_modules/node-datachannel/dist/types/polyfill/RTCSessionDescription.d.ts +0 -10
  418. package/node_modules/node-datachannel/dist/types/polyfill/index.d.ts +0 -26
  419. package/node_modules/node-datachannel/jest.config.ts +0 -14
  420. package/node_modules/node-datachannel/package.json +0 -133
  421. package/node_modules/node-datachannel/rollup.config.mjs +0 -67
  422. package/node_modules/node-datachannel/src/cpp/data-channel-wrapper.cpp +0 -530
  423. package/node_modules/node-datachannel/src/cpp/data-channel-wrapper.h +0 -63
  424. package/node_modules/node-datachannel/src/cpp/ice-udp-mux-listener-wrapper.cpp +0 -172
  425. package/node_modules/node-datachannel/src/cpp/ice-udp-mux-listener-wrapper.h +0 -43
  426. package/node_modules/node-datachannel/src/cpp/main.cpp +0 -58
  427. package/node_modules/node-datachannel/src/cpp/media-audio-wrapper.cpp +0 -457
  428. package/node_modules/node-datachannel/src/cpp/media-audio-wrapper.h +0 -52
  429. package/node_modules/node-datachannel/src/cpp/media-av1packetization.cpp +0 -24
  430. package/node_modules/node-datachannel/src/cpp/media-av1packetization.h +0 -11
  431. package/node_modules/node-datachannel/src/cpp/media-av1rtppacketizer-wrapper.cpp +0 -126
  432. package/node_modules/node-datachannel/src/cpp/media-av1rtppacketizer-wrapper.h +0 -29
  433. package/node_modules/node-datachannel/src/cpp/media-direction.cpp +0 -43
  434. package/node_modules/node-datachannel/src/cpp/media-direction.h +0 -10
  435. package/node_modules/node-datachannel/src/cpp/media-h264rtppacketizer-wrapper.cpp +0 -126
  436. package/node_modules/node-datachannel/src/cpp/media-h264rtppacketizer-wrapper.h +0 -30
  437. package/node_modules/node-datachannel/src/cpp/media-h265rtppacketizer-wrapper.cpp +0 -126
  438. package/node_modules/node-datachannel/src/cpp/media-h265rtppacketizer-wrapper.h +0 -30
  439. package/node_modules/node-datachannel/src/cpp/media-h26xseparator.cpp +0 -32
  440. package/node_modules/node-datachannel/src/cpp/media-h26xseparator.h +0 -11
  441. package/node_modules/node-datachannel/src/cpp/media-mediahandler-helper.cpp +0 -31
  442. package/node_modules/node-datachannel/src/cpp/media-mediahandler-helper.h +0 -11
  443. package/node_modules/node-datachannel/src/cpp/media-pacinghandler-wrapper.cpp +0 -79
  444. package/node_modules/node-datachannel/src/cpp/media-pacinghandler-wrapper.h +0 -28
  445. package/node_modules/node-datachannel/src/cpp/media-rtcpnackresponder-wrapper.cpp +0 -68
  446. package/node_modules/node-datachannel/src/cpp/media-rtcpnackresponder-wrapper.h +0 -28
  447. package/node_modules/node-datachannel/src/cpp/media-rtcpreceivingsession-wrapper.cpp +0 -57
  448. package/node_modules/node-datachannel/src/cpp/media-rtcpreceivingsession-wrapper.h +0 -28
  449. package/node_modules/node-datachannel/src/cpp/media-rtcpsrreporter-wrapper.cpp +0 -93
  450. package/node_modules/node-datachannel/src/cpp/media-rtcpsrreporter-wrapper.h +0 -30
  451. package/node_modules/node-datachannel/src/cpp/media-rtppacketizationconfig-wrapper.cpp +0 -167
  452. package/node_modules/node-datachannel/src/cpp/media-rtppacketizationconfig-wrapper.h +0 -35
  453. package/node_modules/node-datachannel/src/cpp/media-rtppacketizer-wrapper.cpp +0 -95
  454. package/node_modules/node-datachannel/src/cpp/media-rtppacketizer-wrapper.h +0 -30
  455. package/node_modules/node-datachannel/src/cpp/media-track-wrapper.cpp +0 -458
  456. package/node_modules/node-datachannel/src/cpp/media-track-wrapper.h +0 -61
  457. package/node_modules/node-datachannel/src/cpp/media-video-wrapper.cpp +0 -526
  458. package/node_modules/node-datachannel/src/cpp/media-video-wrapper.h +0 -56
  459. package/node_modules/node-datachannel/src/cpp/peer-connection-wrapper.cpp +0 -1298
  460. package/node_modules/node-datachannel/src/cpp/peer-connection-wrapper.h +0 -89
  461. package/node_modules/node-datachannel/src/cpp/rtc-wrapper.cpp +0 -205
  462. package/node_modules/node-datachannel/src/cpp/rtc-wrapper.h +0 -24
  463. package/node_modules/node-datachannel/src/cpp/thread-safe-callback.cpp +0 -57
  464. package/node_modules/node-datachannel/src/cpp/thread-safe-callback.h +0 -47
  465. package/node_modules/node-datachannel/src/cpp/web-socket-server-wrapper.cpp +0 -275
  466. package/node_modules/node-datachannel/src/cpp/web-socket-server-wrapper.h +0 -41
  467. package/node_modules/node-datachannel/src/cpp/web-socket-wrapper.cpp +0 -796
  468. package/node_modules/node-datachannel/src/cpp/web-socket-wrapper.h +0 -63
  469. package/node_modules/node-datachannel/src/index.ts +0 -9
  470. package/node_modules/node-datachannel/src/lib/datachannel-stream.ts +0 -100
  471. package/node_modules/node-datachannel/src/lib/index.ts +0 -290
  472. package/node_modules/node-datachannel/src/lib/node-datachannel.ts +0 -84
  473. package/node_modules/node-datachannel/src/lib/types.ts +0 -169
  474. package/node_modules/node-datachannel/src/lib/websocket-server.ts +0 -37
  475. package/node_modules/node-datachannel/src/lib/websocket.ts +0 -26
  476. package/node_modules/node-datachannel/src/polyfill/Events.ts +0 -82
  477. package/node_modules/node-datachannel/src/polyfill/Exception.ts +0 -37
  478. package/node_modules/node-datachannel/src/polyfill/README.md +0 -41
  479. package/node_modules/node-datachannel/src/polyfill/RTCCertificate.ts +0 -21
  480. package/node_modules/node-datachannel/src/polyfill/RTCDataChannel.ts +0 -225
  481. package/node_modules/node-datachannel/src/polyfill/RTCDtlsTransport.ts +0 -46
  482. package/node_modules/node-datachannel/src/polyfill/RTCError.ts +0 -78
  483. package/node_modules/node-datachannel/src/polyfill/RTCIceCandidate.ts +0 -128
  484. package/node_modules/node-datachannel/src/polyfill/RTCIceTransport.ts +0 -90
  485. package/node_modules/node-datachannel/src/polyfill/RTCPeerConnection.ts +0 -527
  486. package/node_modules/node-datachannel/src/polyfill/RTCSctpTransport.ts +0 -51
  487. package/node_modules/node-datachannel/src/polyfill/RTCSessionDescription.ts +0 -41
  488. package/node_modules/node-datachannel/src/polyfill/index.ts +0 -38
  489. package/node_modules/node-datachannel/tsconfig.json +0 -21
  490. package/node_modules/p-limit/index.d.ts +0 -38
  491. package/node_modules/p-limit/index.js +0 -57
  492. package/node_modules/p-limit/license +0 -9
  493. package/node_modules/p-limit/package.json +0 -52
  494. package/node_modules/p-limit/readme.md +0 -101
  495. package/node_modules/p-locate/index.d.ts +0 -64
  496. package/node_modules/p-locate/index.js +0 -52
  497. package/node_modules/p-locate/license +0 -9
  498. package/node_modules/p-locate/package.json +0 -53
  499. package/node_modules/p-locate/readme.md +0 -90
  500. package/node_modules/p-try/index.d.ts +0 -39
  501. package/node_modules/p-try/index.js +0 -9
  502. package/node_modules/p-try/license +0 -9
  503. package/node_modules/p-try/package.json +0 -42
  504. package/node_modules/p-try/readme.md +0 -58
  505. package/node_modules/path-exists/index.d.ts +0 -28
  506. package/node_modules/path-exists/index.js +0 -23
  507. package/node_modules/path-exists/license +0 -9
  508. package/node_modules/path-exists/package.json +0 -39
  509. package/node_modules/path-exists/readme.md +0 -52
  510. package/node_modules/pngjs/.eslintignore +0 -2
  511. package/node_modules/pngjs/.eslintrc.json +0 -19
  512. package/node_modules/pngjs/.prettierignore +0 -3
  513. package/node_modules/pngjs/LICENSE +0 -20
  514. package/node_modules/pngjs/README.md +0 -429
  515. package/node_modules/pngjs/browser.js +0 -16096
  516. package/node_modules/pngjs/coverage/lcov-report/base.css +0 -354
  517. package/node_modules/pngjs/coverage/lcov-report/bitmapper.js.html +0 -881
  518. package/node_modules/pngjs/coverage/lcov-report/bitpacker.js.html +0 -554
  519. package/node_modules/pngjs/coverage/lcov-report/block-navigation.js +0 -77
  520. package/node_modules/pngjs/coverage/lcov-report/chunkstream.js.html +0 -647
  521. package/node_modules/pngjs/coverage/lcov-report/constants.js.html +0 -176
  522. package/node_modules/pngjs/coverage/lcov-report/crc.js.html +0 -200
  523. package/node_modules/pngjs/coverage/lcov-report/favicon.png +0 -0
  524. package/node_modules/pngjs/coverage/lcov-report/filter-pack.js.html +0 -593
  525. package/node_modules/pngjs/coverage/lcov-report/filter-parse-async.js.html +0 -152
  526. package/node_modules/pngjs/coverage/lcov-report/filter-parse-sync.js.html +0 -143
  527. package/node_modules/pngjs/coverage/lcov-report/filter-parse.js.html +0 -611
  528. package/node_modules/pngjs/coverage/lcov-report/format-normaliser.js.html +0 -359
  529. package/node_modules/pngjs/coverage/lcov-report/index.html +0 -426
  530. package/node_modules/pngjs/coverage/lcov-report/interlace.js.html +0 -365
  531. package/node_modules/pngjs/coverage/lcov-report/packer-async.js.html +0 -230
  532. package/node_modules/pngjs/coverage/lcov-report/packer-sync.js.html +0 -248
  533. package/node_modules/pngjs/coverage/lcov-report/packer.js.html +0 -467
  534. package/node_modules/pngjs/coverage/lcov-report/paeth-predictor.js.html +0 -128
  535. package/node_modules/pngjs/coverage/lcov-report/parser-async.js.html +0 -575
  536. package/node_modules/pngjs/coverage/lcov-report/parser-sync.js.html +0 -404
  537. package/node_modules/pngjs/coverage/lcov-report/parser.js.html +0 -950
  538. package/node_modules/pngjs/coverage/lcov-report/png-sync.js.html +0 -116
  539. package/node_modules/pngjs/coverage/lcov-report/png.js.html +0 -662
  540. package/node_modules/pngjs/coverage/lcov-report/prettify.css +0 -101
  541. package/node_modules/pngjs/coverage/lcov-report/prettify.js +0 -1007
  542. package/node_modules/pngjs/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  543. package/node_modules/pngjs/coverage/lcov-report/sorter.js +0 -169
  544. package/node_modules/pngjs/coverage/lcov-report/sync-inflate.js.html +0 -584
  545. package/node_modules/pngjs/coverage/lcov-report/sync-reader.js.html +0 -215
  546. package/node_modules/pngjs/coverage/lcov.info +0 -2177
  547. package/node_modules/pngjs/lib/bitmapper.js +0 -267
  548. package/node_modules/pngjs/lib/bitpacker.js +0 -158
  549. package/node_modules/pngjs/lib/chunkstream.js +0 -189
  550. package/node_modules/pngjs/lib/constants.js +0 -32
  551. package/node_modules/pngjs/lib/crc.js +0 -40
  552. package/node_modules/pngjs/lib/filter-pack.js +0 -171
  553. package/node_modules/pngjs/lib/filter-parse-async.js +0 -24
  554. package/node_modules/pngjs/lib/filter-parse-sync.js +0 -21
  555. package/node_modules/pngjs/lib/filter-parse.js +0 -177
  556. package/node_modules/pngjs/lib/format-normaliser.js +0 -93
  557. package/node_modules/pngjs/lib/interlace.js +0 -95
  558. package/node_modules/pngjs/lib/packer-async.js +0 -50
  559. package/node_modules/pngjs/lib/packer-sync.js +0 -56
  560. package/node_modules/pngjs/lib/packer.js +0 -129
  561. package/node_modules/pngjs/lib/paeth-predictor.js +0 -16
  562. package/node_modules/pngjs/lib/parser-async.js +0 -165
  563. package/node_modules/pngjs/lib/parser-sync.js +0 -108
  564. package/node_modules/pngjs/lib/parser.js +0 -290
  565. package/node_modules/pngjs/lib/png-sync.js +0 -12
  566. package/node_modules/pngjs/lib/png.js +0 -194
  567. package/node_modules/pngjs/lib/sync-inflate.js +0 -168
  568. package/node_modules/pngjs/lib/sync-reader.js +0 -45
  569. package/node_modules/pngjs/package.json +0 -73
  570. package/node_modules/qrcode/README.md +0 -770
  571. package/node_modules/qrcode/bin/qrcode +0 -159
  572. package/node_modules/qrcode/helper/to-sjis-browser.js +0 -2
  573. package/node_modules/qrcode/helper/to-sjis.js +0 -105
  574. package/node_modules/qrcode/lib/browser.js +0 -76
  575. package/node_modules/qrcode/lib/can-promise.js +0 -7
  576. package/node_modules/qrcode/lib/core/alignment-pattern.js +0 -83
  577. package/node_modules/qrcode/lib/core/alphanumeric-data.js +0 -59
  578. package/node_modules/qrcode/lib/core/bit-buffer.js +0 -37
  579. package/node_modules/qrcode/lib/core/bit-matrix.js +0 -65
  580. package/node_modules/qrcode/lib/core/byte-data.js +0 -30
  581. package/node_modules/qrcode/lib/core/error-correction-code.js +0 -135
  582. package/node_modules/qrcode/lib/core/error-correction-level.js +0 -50
  583. package/node_modules/qrcode/lib/core/finder-pattern.js +0 -22
  584. package/node_modules/qrcode/lib/core/format-info.js +0 -29
  585. package/node_modules/qrcode/lib/core/galois-field.js +0 -69
  586. package/node_modules/qrcode/lib/core/kanji-data.js +0 -54
  587. package/node_modules/qrcode/lib/core/mask-pattern.js +0 -234
  588. package/node_modules/qrcode/lib/core/mode.js +0 -167
  589. package/node_modules/qrcode/lib/core/numeric-data.js +0 -43
  590. package/node_modules/qrcode/lib/core/polynomial.js +0 -62
  591. package/node_modules/qrcode/lib/core/qrcode.js +0 -495
  592. package/node_modules/qrcode/lib/core/reed-solomon-encoder.js +0 -56
  593. package/node_modules/qrcode/lib/core/regex.js +0 -31
  594. package/node_modules/qrcode/lib/core/segments.js +0 -330
  595. package/node_modules/qrcode/lib/core/utils.js +0 -63
  596. package/node_modules/qrcode/lib/core/version-check.js +0 -9
  597. package/node_modules/qrcode/lib/core/version.js +0 -163
  598. package/node_modules/qrcode/lib/index.js +0 -12
  599. package/node_modules/qrcode/lib/renderer/canvas.js +0 -63
  600. package/node_modules/qrcode/lib/renderer/png.js +0 -78
  601. package/node_modules/qrcode/lib/renderer/svg-tag.js +0 -81
  602. package/node_modules/qrcode/lib/renderer/svg.js +0 -19
  603. package/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +0 -85
  604. package/node_modules/qrcode/lib/renderer/terminal/terminal.js +0 -49
  605. package/node_modules/qrcode/lib/renderer/terminal.js +0 -9
  606. package/node_modules/qrcode/lib/renderer/utf8.js +0 -71
  607. package/node_modules/qrcode/lib/renderer/utils.js +0 -99
  608. package/node_modules/qrcode/lib/server.js +0 -138
  609. package/node_modules/qrcode/license +0 -10
  610. package/node_modules/qrcode/package.json +0 -77
  611. package/node_modules/require-directory/.jshintrc +0 -67
  612. package/node_modules/require-directory/.npmignore +0 -1
  613. package/node_modules/require-directory/.travis.yml +0 -3
  614. package/node_modules/require-directory/LICENSE +0 -22
  615. package/node_modules/require-directory/README.markdown +0 -184
  616. package/node_modules/require-directory/index.js +0 -86
  617. package/node_modules/require-directory/package.json +0 -40
  618. package/node_modules/require-main-filename/CHANGELOG.md +0 -26
  619. package/node_modules/require-main-filename/LICENSE.txt +0 -14
  620. package/node_modules/require-main-filename/README.md +0 -26
  621. package/node_modules/require-main-filename/index.js +0 -18
  622. package/node_modules/require-main-filename/package.json +0 -35
  623. package/node_modules/semver/LICENSE +0 -15
  624. package/node_modules/semver/README.md +0 -680
  625. package/node_modules/semver/bin/semver.js +0 -195
  626. package/node_modules/semver/classes/comparator.js +0 -143
  627. package/node_modules/semver/classes/index.js +0 -7
  628. package/node_modules/semver/classes/range.js +0 -577
  629. package/node_modules/semver/classes/semver.js +0 -350
  630. package/node_modules/semver/functions/clean.js +0 -8
  631. package/node_modules/semver/functions/cmp.js +0 -54
  632. package/node_modules/semver/functions/coerce.js +0 -62
  633. package/node_modules/semver/functions/compare-build.js +0 -9
  634. package/node_modules/semver/functions/compare-loose.js +0 -5
  635. package/node_modules/semver/functions/compare.js +0 -7
  636. package/node_modules/semver/functions/diff.js +0 -60
  637. package/node_modules/semver/functions/eq.js +0 -5
  638. package/node_modules/semver/functions/gt.js +0 -5
  639. package/node_modules/semver/functions/gte.js +0 -5
  640. package/node_modules/semver/functions/inc.js +0 -21
  641. package/node_modules/semver/functions/lt.js +0 -5
  642. package/node_modules/semver/functions/lte.js +0 -5
  643. package/node_modules/semver/functions/major.js +0 -5
  644. package/node_modules/semver/functions/minor.js +0 -5
  645. package/node_modules/semver/functions/neq.js +0 -5
  646. package/node_modules/semver/functions/parse.js +0 -18
  647. package/node_modules/semver/functions/patch.js +0 -5
  648. package/node_modules/semver/functions/prerelease.js +0 -8
  649. package/node_modules/semver/functions/rcompare.js +0 -5
  650. package/node_modules/semver/functions/rsort.js +0 -5
  651. package/node_modules/semver/functions/satisfies.js +0 -12
  652. package/node_modules/semver/functions/sort.js +0 -5
  653. package/node_modules/semver/functions/truncate.js +0 -48
  654. package/node_modules/semver/functions/valid.js +0 -8
  655. package/node_modules/semver/index.js +0 -93
  656. package/node_modules/semver/internal/constants.js +0 -37
  657. package/node_modules/semver/internal/debug.js +0 -11
  658. package/node_modules/semver/internal/identifiers.js +0 -29
  659. package/node_modules/semver/internal/lrucache.js +0 -42
  660. package/node_modules/semver/internal/parse-options.js +0 -17
  661. package/node_modules/semver/internal/re.js +0 -223
  662. package/node_modules/semver/package.json +0 -78
  663. package/node_modules/semver/preload.js +0 -4
  664. package/node_modules/semver/range.bnf +0 -17
  665. package/node_modules/semver/ranges/gtr.js +0 -6
  666. package/node_modules/semver/ranges/intersects.js +0 -9
  667. package/node_modules/semver/ranges/ltr.js +0 -6
  668. package/node_modules/semver/ranges/max-satisfying.js +0 -27
  669. package/node_modules/semver/ranges/min-satisfying.js +0 -26
  670. package/node_modules/semver/ranges/min-version.js +0 -63
  671. package/node_modules/semver/ranges/outside.js +0 -82
  672. package/node_modules/semver/ranges/simplify.js +0 -49
  673. package/node_modules/semver/ranges/subset.js +0 -249
  674. package/node_modules/semver/ranges/to-comparators.js +0 -10
  675. package/node_modules/semver/ranges/valid.js +0 -13
  676. package/node_modules/set-blocking/CHANGELOG.md +0 -26
  677. package/node_modules/set-blocking/LICENSE.txt +0 -14
  678. package/node_modules/set-blocking/README.md +0 -31
  679. package/node_modules/set-blocking/index.js +0 -7
  680. package/node_modules/set-blocking/package.json +0 -42
  681. package/node_modules/sharp/LICENSE +0 -191
  682. package/node_modules/sharp/README.md +0 -112
  683. package/node_modules/sharp/dist/channel.cjs +0 -177
  684. package/node_modules/sharp/dist/channel.mjs +0 -177
  685. package/node_modules/sharp/dist/colour.cjs +0 -199
  686. package/node_modules/sharp/dist/colour.mjs +0 -199
  687. package/node_modules/sharp/dist/composite.cjs +0 -213
  688. package/node_modules/sharp/dist/composite.mjs +0 -213
  689. package/node_modules/sharp/dist/constructor.cjs +0 -511
  690. package/node_modules/sharp/dist/constructor.mjs +0 -511
  691. package/node_modules/sharp/dist/index.cjs +0 -25
  692. package/node_modules/sharp/dist/index.d.cts +0 -1999
  693. package/node_modules/sharp/dist/index.d.mts +0 -2046
  694. package/node_modules/sharp/dist/index.mjs +0 -25
  695. package/node_modules/sharp/dist/input.cjs +0 -819
  696. package/node_modules/sharp/dist/input.mjs +0 -819
  697. package/node_modules/sharp/dist/is.cjs +0 -143
  698. package/node_modules/sharp/dist/is.mjs +0 -143
  699. package/node_modules/sharp/dist/libvips.cjs +0 -212
  700. package/node_modules/sharp/dist/libvips.mjs +0 -212
  701. package/node_modules/sharp/dist/operation.cjs +0 -1002
  702. package/node_modules/sharp/dist/operation.mjs +0 -1002
  703. package/node_modules/sharp/dist/output.cjs +0 -1785
  704. package/node_modules/sharp/dist/output.mjs +0 -1785
  705. package/node_modules/sharp/dist/resize.cjs +0 -617
  706. package/node_modules/sharp/dist/resize.mjs +0 -617
  707. package/node_modules/sharp/dist/sharp.cjs +0 -174
  708. package/node_modules/sharp/dist/sharp.mjs +0 -174
  709. package/node_modules/sharp/dist/utility.cjs +0 -301
  710. package/node_modules/sharp/dist/utility.mjs +0 -301
  711. package/node_modules/sharp/install/build.js +0 -38
  712. package/node_modules/sharp/lib/index.d.ts +0 -1999
  713. package/node_modules/sharp/package.json +0 -227
  714. package/node_modules/sharp/src/binding.gyp +0 -303
  715. package/node_modules/sharp/src/common.cc +0 -1186
  716. package/node_modules/sharp/src/common.h +0 -421
  717. package/node_modules/sharp/src/metadata.cc +0 -404
  718. package/node_modules/sharp/src/metadata.h +0 -95
  719. package/node_modules/sharp/src/operations.cc +0 -516
  720. package/node_modules/sharp/src/operations.h +0 -137
  721. package/node_modules/sharp/src/pipeline.cc +0 -1948
  722. package/node_modules/sharp/src/pipeline.h +0 -422
  723. package/node_modules/sharp/src/sharp.cc +0 -43
  724. package/node_modules/sharp/src/stats.cc +0 -186
  725. package/node_modules/sharp/src/stats.h +0 -62
  726. package/node_modules/sharp/src/utilities.cc +0 -289
  727. package/node_modules/sharp/src/utilities.h +0 -22
  728. package/node_modules/string-width/index.d.ts +0 -29
  729. package/node_modules/string-width/index.js +0 -47
  730. package/node_modules/string-width/license +0 -9
  731. package/node_modules/string-width/package.json +0 -56
  732. package/node_modules/string-width/readme.md +0 -50
  733. package/node_modules/strip-ansi/index.d.ts +0 -17
  734. package/node_modules/strip-ansi/index.js +0 -4
  735. package/node_modules/strip-ansi/license +0 -9
  736. package/node_modules/strip-ansi/package.json +0 -54
  737. package/node_modules/strip-ansi/readme.md +0 -46
  738. package/node_modules/which-module/LICENSE +0 -13
  739. package/node_modules/which-module/README.md +0 -58
  740. package/node_modules/which-module/index.js +0 -9
  741. package/node_modules/which-module/package.json +0 -41
  742. package/node_modules/wrap-ansi/index.js +0 -186
  743. package/node_modules/wrap-ansi/license +0 -9
  744. package/node_modules/wrap-ansi/package.json +0 -61
  745. package/node_modules/wrap-ansi/readme.md +0 -97
  746. package/node_modules/ws/LICENSE +0 -20
  747. package/node_modules/ws/README.md +0 -548
  748. package/node_modules/ws/browser.js +0 -8
  749. package/node_modules/ws/index.js +0 -22
  750. package/node_modules/ws/lib/buffer-util.js +0 -131
  751. package/node_modules/ws/lib/constants.js +0 -19
  752. package/node_modules/ws/lib/event-target.js +0 -292
  753. package/node_modules/ws/lib/extension.js +0 -203
  754. package/node_modules/ws/lib/limiter.js +0 -55
  755. package/node_modules/ws/lib/permessage-deflate.js +0 -530
  756. package/node_modules/ws/lib/receiver.js +0 -743
  757. package/node_modules/ws/lib/sender.js +0 -607
  758. package/node_modules/ws/lib/stream.js +0 -161
  759. package/node_modules/ws/lib/subprotocol.js +0 -62
  760. package/node_modules/ws/lib/validation.js +0 -152
  761. package/node_modules/ws/lib/websocket-server.js +0 -562
  762. package/node_modules/ws/lib/websocket.js +0 -1407
  763. package/node_modules/ws/package.json +0 -74
  764. package/node_modules/ws/wrapper.mjs +0 -21
  765. package/node_modules/y18n/CHANGELOG.md +0 -35
  766. package/node_modules/y18n/LICENSE +0 -13
  767. package/node_modules/y18n/README.md +0 -109
  768. package/node_modules/y18n/index.js +0 -188
  769. package/node_modules/y18n/package.json +0 -39
  770. package/node_modules/yargs/CHANGELOG.md +0 -420
  771. package/node_modules/yargs/LICENSE +0 -21
  772. package/node_modules/yargs/README.md +0 -140
  773. package/node_modules/yargs/build/lib/apply-extends.d.ts +0 -2
  774. package/node_modules/yargs/build/lib/apply-extends.js +0 -65
  775. package/node_modules/yargs/build/lib/argsert.d.ts +0 -2
  776. package/node_modules/yargs/build/lib/argsert.js +0 -65
  777. package/node_modules/yargs/build/lib/command.d.ts +0 -64
  778. package/node_modules/yargs/build/lib/command.js +0 -416
  779. package/node_modules/yargs/build/lib/common-types.d.ts +0 -36
  780. package/node_modules/yargs/build/lib/common-types.js +0 -25
  781. package/node_modules/yargs/build/lib/completion-templates.d.ts +0 -2
  782. package/node_modules/yargs/build/lib/completion-templates.js +0 -50
  783. package/node_modules/yargs/build/lib/completion.d.ts +0 -21
  784. package/node_modules/yargs/build/lib/completion.js +0 -135
  785. package/node_modules/yargs/build/lib/is-promise.d.ts +0 -1
  786. package/node_modules/yargs/build/lib/is-promise.js +0 -9
  787. package/node_modules/yargs/build/lib/levenshtein.d.ts +0 -1
  788. package/node_modules/yargs/build/lib/levenshtein.js +0 -58
  789. package/node_modules/yargs/build/lib/middleware.d.ts +0 -10
  790. package/node_modules/yargs/build/lib/middleware.js +0 -57
  791. package/node_modules/yargs/build/lib/obj-filter.d.ts +0 -1
  792. package/node_modules/yargs/build/lib/obj-filter.js +0 -14
  793. package/node_modules/yargs/build/lib/parse-command.d.ts +0 -11
  794. package/node_modules/yargs/build/lib/parse-command.js +0 -36
  795. package/node_modules/yargs/build/lib/process-argv.d.ts +0 -2
  796. package/node_modules/yargs/build/lib/process-argv.js +0 -31
  797. package/node_modules/yargs/build/lib/usage.d.ts +0 -49
  798. package/node_modules/yargs/build/lib/usage.js +0 -540
  799. package/node_modules/yargs/build/lib/validation.d.ts +0 -34
  800. package/node_modules/yargs/build/lib/validation.js +0 -330
  801. package/node_modules/yargs/build/lib/yargs.d.ts +0 -274
  802. package/node_modules/yargs/build/lib/yargs.js +0 -1190
  803. package/node_modules/yargs/build/lib/yerror.d.ts +0 -4
  804. package/node_modules/yargs/build/lib/yerror.js +0 -11
  805. package/node_modules/yargs/index.js +0 -40
  806. package/node_modules/yargs/locales/be.json +0 -46
  807. package/node_modules/yargs/locales/de.json +0 -46
  808. package/node_modules/yargs/locales/en.json +0 -51
  809. package/node_modules/yargs/locales/es.json +0 -46
  810. package/node_modules/yargs/locales/fi.json +0 -49
  811. package/node_modules/yargs/locales/fr.json +0 -53
  812. package/node_modules/yargs/locales/hi.json +0 -49
  813. package/node_modules/yargs/locales/hu.json +0 -46
  814. package/node_modules/yargs/locales/id.json +0 -50
  815. package/node_modules/yargs/locales/it.json +0 -46
  816. package/node_modules/yargs/locales/ja.json +0 -51
  817. package/node_modules/yargs/locales/ko.json +0 -49
  818. package/node_modules/yargs/locales/nb.json +0 -44
  819. package/node_modules/yargs/locales/nl.json +0 -49
  820. package/node_modules/yargs/locales/nn.json +0 -44
  821. package/node_modules/yargs/locales/pirate.json +0 -13
  822. package/node_modules/yargs/locales/pl.json +0 -49
  823. package/node_modules/yargs/locales/pt.json +0 -45
  824. package/node_modules/yargs/locales/pt_BR.json +0 -48
  825. package/node_modules/yargs/locales/ru.json +0 -46
  826. package/node_modules/yargs/locales/th.json +0 -46
  827. package/node_modules/yargs/locales/tr.json +0 -48
  828. package/node_modules/yargs/locales/zh_CN.json +0 -48
  829. package/node_modules/yargs/locales/zh_TW.json +0 -47
  830. package/node_modules/yargs/package.json +0 -92
  831. package/node_modules/yargs/yargs.js +0 -14
  832. package/node_modules/yargs-parser/CHANGELOG.md +0 -601
  833. package/node_modules/yargs-parser/LICENSE.txt +0 -14
  834. package/node_modules/yargs-parser/README.md +0 -449
  835. package/node_modules/yargs-parser/index.js +0 -1032
  836. package/node_modules/yargs-parser/lib/tokenize-arg-string.js +0 -40
  837. package/node_modules/yargs-parser/package.json +0 -46
@@ -1,1948 +0,0 @@
1
- /*!
2
- Copyright 2013 Lovell Fuller and others.
3
- SPDX-License-Identifier: Apache-2.0
4
- */
5
-
6
- #include <algorithm>
7
- #include <cmath>
8
- #include <filesystem> // NOLINT(build/c++17)
9
- #include <map>
10
- #include <memory>
11
- #include <numeric>
12
- #include <string>
13
- #include <tuple>
14
- #include <utility>
15
- #include <vector>
16
- #include <sys/types.h>
17
- #include <sys/stat.h>
18
-
19
- #include <vips/vips8>
20
- #include <napi.h>
21
-
22
- #include "./common.h"
23
- #include "./operations.h"
24
- #include "./pipeline.h"
25
-
26
- class PipelineWorker : public Napi::AsyncWorker {
27
- public:
28
- PipelineWorker(Napi::Function callback, PipelineBaton *baton,
29
- Napi::Function debuglog, Napi::Function queueListener) :
30
- Napi::AsyncWorker(callback),
31
- baton(baton),
32
- debuglog(Napi::Persistent(debuglog)),
33
- queueListener(Napi::Persistent(queueListener)) {}
34
- ~PipelineWorker() {}
35
-
36
- // libuv worker
37
- void Execute() {
38
- // Decrement queued task counter
39
- sharp::counterQueue--;
40
- // Increment processing task counter
41
- sharp::counterProcess++;
42
-
43
- try {
44
- // Open input
45
- vips::VImage image;
46
- sharp::ImageType inputImageType;
47
- if (baton->join.empty()) {
48
- std::tie(image, inputImageType) = sharp::OpenInput(baton->input);
49
- } else {
50
- std::vector<VImage> images;
51
- bool hasAlpha = false;
52
- for (auto &join : baton->join) {
53
- std::tie(image, inputImageType) = sharp::OpenInput(join);
54
- image = sharp::EnsureColourspace(image, baton->colourspacePipeline);
55
- images.push_back(image);
56
- hasAlpha |= image.has_alpha();
57
- }
58
- if (hasAlpha) {
59
- for (auto &image : images) {
60
- if (!image.has_alpha()) {
61
- image = sharp::EnsureAlpha(image, 1);
62
- }
63
- }
64
- } else {
65
- baton->input->joinBackground.pop_back();
66
- }
67
- inputImageType = sharp::ImageType::PNG;
68
- image = VImage::arrayjoin(images, VImage::option()
69
- ->set("across", baton->input->joinAcross)
70
- ->set("shim", baton->input->joinShim)
71
- ->set("background", baton->input->joinBackground)
72
- ->set("halign", baton->input->joinHalign)
73
- ->set("valign", baton->input->joinValign));
74
- if (baton->input->joinAnimated) {
75
- image = image.copy();
76
- image.set(VIPS_META_N_PAGES, static_cast<int>(images.size()));
77
- image.set(VIPS_META_PAGE_HEIGHT, static_cast<int>(image.height() / images.size()));
78
- }
79
- }
80
- VipsAccess access = baton->input->access;
81
- image = sharp::EnsureColourspace(image, baton->colourspacePipeline);
82
-
83
- int nPages = baton->input->pages;
84
- if (nPages == -1) {
85
- // Resolve the number of pages if we need to render until the end of the document
86
- nPages = image.get_typeof(VIPS_META_N_PAGES) != 0
87
- ? image.get_int(VIPS_META_N_PAGES) - std::max(0, baton->input->page)
88
- : 1;
89
- }
90
-
91
- // Get pre-resize page height
92
- int pageHeight = sharp::GetPageHeight(image);
93
-
94
- // Calculate angle of rotation
95
- VipsAngle rotation = VIPS_ANGLE_D0;
96
- VipsAngle autoRotation = VIPS_ANGLE_D0;
97
- bool autoFlop = false;
98
-
99
- if (baton->input->autoOrient) {
100
- // Rotate and flip image according to Exif orientation
101
- std::tie(autoRotation, autoFlop) = CalculateExifRotationAndFlop(sharp::ExifOrientation(image));
102
- }
103
-
104
- rotation = CalculateAngleRotation(baton->angle);
105
-
106
- bool const shouldRotateBefore = baton->rotateBefore &&
107
- (rotation != VIPS_ANGLE_D0 || baton->flip || baton->flop || baton->rotationAngle != 0.0);
108
- bool const shouldOrientBefore = (shouldRotateBefore || baton->orientBefore) &&
109
- (autoRotation != VIPS_ANGLE_D0 || autoFlop);
110
-
111
- if (shouldOrientBefore) {
112
- image = sharp::StaySequential(image, autoRotation != VIPS_ANGLE_D0);
113
- if (autoRotation != VIPS_ANGLE_D0) {
114
- if (autoRotation != VIPS_ANGLE_D180) {
115
- MultiPageUnsupported(nPages, "Rotate");
116
- }
117
- image = image.rot(autoRotation);
118
- autoRotation = VIPS_ANGLE_D0;
119
- }
120
- if (autoFlop) {
121
- image = image.flip(VIPS_DIRECTION_HORIZONTAL);
122
- autoFlop = false;
123
- }
124
- }
125
-
126
- if (shouldRotateBefore) {
127
- image = sharp::StaySequential(image, rotation != VIPS_ANGLE_D0 || baton->flip || baton->rotationAngle != 0.0);
128
- if (baton->flip) {
129
- image = image.flip(VIPS_DIRECTION_VERTICAL);
130
- baton->flip = false;
131
- }
132
- if (baton->flop) {
133
- image = image.flip(VIPS_DIRECTION_HORIZONTAL);
134
- baton->flop = false;
135
- }
136
- if (rotation != VIPS_ANGLE_D0) {
137
- if (rotation != VIPS_ANGLE_D180) {
138
- MultiPageUnsupported(nPages, "Rotate");
139
- }
140
- image = image.rot(rotation);
141
- rotation = VIPS_ANGLE_D0;
142
- }
143
- if (baton->rotationAngle != 0.0) {
144
- MultiPageUnsupported(nPages, "Rotate");
145
- std::vector<double> background;
146
- std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground, false);
147
- image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background)).copy_memory();
148
- baton->rotationAngle = 0.0;
149
- }
150
- }
151
-
152
- // Trim
153
- if (baton->trimThreshold >= 0.0) {
154
- MultiPageUnsupported(nPages, "Trim");
155
- image = sharp::StaySequential(image);
156
- image = sharp::Trim(image, baton->trimBackground, baton->trimThreshold, baton->trimLineArt, baton->trimMargin);
157
- baton->trimOffsetLeft = image.xoffset();
158
- baton->trimOffsetTop = image.yoffset();
159
- }
160
-
161
- // Pre extraction
162
- if (baton->topOffsetPre != -1) {
163
- image = nPages > 1
164
- ? sharp::CropMultiPage(image,
165
- baton->leftOffsetPre, baton->topOffsetPre, baton->widthPre, baton->heightPre, nPages, &pageHeight)
166
- : image.extract_area(baton->leftOffsetPre, baton->topOffsetPre, baton->widthPre, baton->heightPre);
167
- }
168
-
169
- // Get pre-resize image width and height
170
- int inputWidth = image.width();
171
- int inputHeight = image.height();
172
-
173
- // Is there just one page? Shrink to inputHeight instead
174
- if (nPages == 1) {
175
- pageHeight = inputHeight;
176
- }
177
-
178
- // Scaling calculations
179
- double hshrink;
180
- double vshrink;
181
- int targetResizeWidth = baton->width;
182
- int targetResizeHeight = baton->height;
183
-
184
- // When auto-rotating by 90 or 270 degrees, swap the target width and
185
- // height to ensure the behavior aligns with how it would have been if
186
- // the rotation had taken place *before* resizing.
187
- if (autoRotation == VIPS_ANGLE_D90 || autoRotation == VIPS_ANGLE_D270) {
188
- std::swap(targetResizeWidth, targetResizeHeight);
189
- }
190
-
191
- // Shrink to pageHeight, so we work for multi-page images
192
- std::tie(hshrink, vshrink) = sharp::ResolveShrink(
193
- inputWidth, pageHeight, targetResizeWidth, targetResizeHeight,
194
- baton->canvas, baton->withoutEnlargement, baton->withoutReduction);
195
-
196
- // The jpeg preload shrink.
197
- int jpegShrinkOnLoad = 1;
198
-
199
- // WebP, PDF, SVG scale
200
- double scale = 1.0;
201
-
202
- // Try to reload input using shrink-on-load for JPEG, WebP, SVG and PDF, when:
203
- // - the width or height parameters are specified;
204
- // - gamma correction doesn't need to be applied;
205
- // - trimming or pre-resize extract isn't required;
206
- // - gain map processing is not required;
207
- // - input colourspace is not specified;
208
- bool const shouldPreShrink = (targetResizeWidth > 0 || targetResizeHeight > 0) &&
209
- baton->gamma == 0 && baton->topOffsetPre == -1 && baton->trimThreshold < 0.0 &&
210
- !baton->keepGainMap && !baton->withGainMap &&
211
- baton->colourspacePipeline == VIPS_INTERPRETATION_LAST && !(shouldOrientBefore || shouldRotateBefore);
212
-
213
- if (shouldPreShrink) {
214
- // The common part of the shrink: the bit by which both axes must be shrunk
215
- double shrink = std::min(hshrink, vshrink);
216
-
217
- if (inputImageType == sharp::ImageType::JPEG) {
218
- // Leave at least a factor of two for the final resize step, when fastShrinkOnLoad: false
219
- // for more consistent results and to avoid extra sharpness to the image
220
- int factor = baton->fastShrinkOnLoad ? 1 : 2;
221
- if (shrink >= 8 * factor) {
222
- jpegShrinkOnLoad = 8;
223
- } else if (shrink >= 4 * factor) {
224
- jpegShrinkOnLoad = 4;
225
- } else if (shrink >= 2 * factor) {
226
- jpegShrinkOnLoad = 2;
227
- }
228
- // Lower shrink-on-load for known libjpeg rounding errors
229
- if (jpegShrinkOnLoad > 1 && static_cast<int>(shrink) == jpegShrinkOnLoad) {
230
- jpegShrinkOnLoad /= 2;
231
- }
232
- } else if (inputImageType == sharp::ImageType::WEBP && baton->fastShrinkOnLoad && shrink > 1.0) {
233
- // Avoid upscaling via webp
234
- scale = 1.0 / shrink;
235
- } else if (inputImageType == sharp::ImageType::SVG ||
236
- inputImageType == sharp::ImageType::PDF) {
237
- scale = 1.0 / shrink;
238
- }
239
- }
240
-
241
- // Reload input using shrink-on-load, it'll be an integer shrink
242
- // factor for jpegload*, a double scale factor for webpload*,
243
- // pdfload* and svgload*
244
- if (jpegShrinkOnLoad > 1) {
245
- vips::VOption *option = GetOptionsForImageType(inputImageType, baton->input)->set("shrink", jpegShrinkOnLoad);
246
- if (baton->input->buffer != nullptr) {
247
- // Reload JPEG buffer
248
- VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
249
- image = VImage::jpegload_buffer(blob, option);
250
- vips_area_unref(reinterpret_cast<VipsArea*>(blob));
251
- } else {
252
- // Reload JPEG file
253
- image = VImage::jpegload(const_cast<char*>(baton->input->file.data()), option);
254
- }
255
- } else if (scale != 1.0) {
256
- vips::VOption *option = GetOptionsForImageType(inputImageType, baton->input)->set("scale", scale);
257
- if (inputImageType == sharp::ImageType::WEBP) {
258
- if (baton->input->buffer != nullptr) {
259
- // Reload WebP buffer
260
- VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
261
- image = VImage::webpload_buffer(blob, option);
262
- vips_area_unref(reinterpret_cast<VipsArea*>(blob));
263
- } else {
264
- // Reload WebP file
265
- image = VImage::webpload(const_cast<char*>(baton->input->file.data()), option);
266
- }
267
- } else if (inputImageType == sharp::ImageType::SVG) {
268
- if (baton->input->buffer != nullptr) {
269
- // Reload SVG buffer
270
- VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
271
- image = VImage::svgload_buffer(blob, option);
272
- vips_area_unref(reinterpret_cast<VipsArea*>(blob));
273
- } else {
274
- // Reload SVG file
275
- image = VImage::svgload(const_cast<char*>(baton->input->file.data()), option);
276
- }
277
- sharp::SetDensity(image, baton->input->density);
278
- if (image.width() > 32767 || image.height() > 32767) {
279
- throw std::runtime_error("Input SVG image will exceed 32767x32767 pixel limit when scaled");
280
- }
281
- } else if (inputImageType == sharp::ImageType::PDF) {
282
- if (baton->input->buffer != nullptr) {
283
- // Reload PDF buffer
284
- VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
285
- image = VImage::pdfload_buffer(blob, option);
286
- vips_area_unref(reinterpret_cast<VipsArea*>(blob));
287
- } else {
288
- // Reload PDF file
289
- image = VImage::pdfload(const_cast<char*>(baton->input->file.data()), option);
290
- }
291
- sharp::SetDensity(image, baton->input->density);
292
- }
293
- } else {
294
- if (inputImageType == sharp::ImageType::SVG && (image.width() > 32767 || image.height() > 32767)) {
295
- throw std::runtime_error("Input SVG image exceeds 32767x32767 pixel limit");
296
- }
297
- }
298
- if (baton->input->autoOrient) {
299
- image = sharp::RemoveExifOrientation(image);
300
- }
301
- VImage gainMap;
302
- int gainMapScaleFactor = 1;
303
- if (sharp::HasGainMap(image)) {
304
- if (baton->keepGainMap) {
305
- gainMap = image.gainmap();
306
- if (image.get_typeof("gainmap-scale-factor") == G_TYPE_INT) {
307
- gainMapScaleFactor = image.get_int("gainmap-scale-factor");
308
- }
309
- } else if (baton->withGainMap) {
310
- image = image.uhdr2scRGB();
311
- }
312
- image = sharp::RemoveGainMap(image);
313
- } else {
314
- baton->keepGainMap = false;
315
- baton->withGainMap = false;
316
- }
317
-
318
- // Any pre-shrinking may already have been done
319
- inputWidth = image.width();
320
- inputHeight = image.height();
321
-
322
- // After pre-shrink, but before the main shrink stage
323
- // Reuse the initial pageHeight if we didn't pre-shrink
324
- if (shouldPreShrink) {
325
- pageHeight = sharp::GetPageHeight(image);
326
- }
327
-
328
- // Shrink to pageHeight, so we work for multi-page images
329
- std::tie(hshrink, vshrink) = sharp::ResolveShrink(
330
- inputWidth, pageHeight, targetResizeWidth, targetResizeHeight,
331
- baton->canvas, baton->withoutEnlargement, baton->withoutReduction);
332
-
333
- int targetHeight = static_cast<int>(std::rint(static_cast<double>(pageHeight) / vshrink));
334
- int targetPageHeight = targetHeight;
335
-
336
- // In toilet-roll mode, we must adjust vshrink so that we exactly hit
337
- // pageHeight or we'll have pixels straddling pixel boundaries
338
- if (inputHeight > pageHeight) {
339
- targetHeight *= nPages;
340
- vshrink = static_cast<double>(inputHeight) / targetHeight;
341
- }
342
-
343
- // Ensure we're using a device-independent colour space
344
- std::pair<char*, size_t> inputProfile(nullptr, 0);
345
- if ((baton->keepMetadata & VIPS_FOREIGN_KEEP_ICC) && baton->withIccProfile.empty()) {
346
- // Cache input profile for use with output
347
- inputProfile = sharp::GetProfile(image);
348
- baton->input->ignoreIcc = true;
349
- }
350
- char const *processingProfile = image.interpretation() == VIPS_INTERPRETATION_RGB16 ? "p3" : "srgb";
351
- if (
352
- sharp::HasProfile(image) &&
353
- image.interpretation() != VIPS_INTERPRETATION_LABS &&
354
- image.interpretation() != VIPS_INTERPRETATION_GREY16 &&
355
- baton->colourspacePipeline != VIPS_INTERPRETATION_CMYK &&
356
- !baton->input->ignoreIcc && !baton->withGainMap
357
- ) {
358
- // Convert to sRGB/P3 using embedded profile
359
- try {
360
- image = image.icc_transform(processingProfile, VImage::option()
361
- ->set("embedded", true)
362
- ->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
363
- ->set("intent", VIPS_INTENT_PERCEPTUAL));
364
- } catch(...) {
365
- sharp::VipsWarningCallback(nullptr, G_LOG_LEVEL_WARNING, "Invalid embedded profile", nullptr);
366
- }
367
- } else if (
368
- image.interpretation() == VIPS_INTERPRETATION_CMYK &&
369
- baton->colourspacePipeline != VIPS_INTERPRETATION_CMYK
370
- ) {
371
- image = image.icc_transform(processingProfile, VImage::option()
372
- ->set("input_profile", "cmyk")
373
- ->set("intent", VIPS_INTENT_PERCEPTUAL));
374
- }
375
-
376
- // Flatten image to remove alpha channel
377
- if (baton->flatten && image.has_alpha()) {
378
- image = sharp::Flatten(image, baton->flattenBackground);
379
- }
380
-
381
- // Gamma encoding (darken)
382
- if (baton->gamma >= 1 && baton->gamma <= 3) {
383
- image = sharp::Gamma(image, 1.0 / baton->gamma);
384
- }
385
-
386
- // Convert to greyscale (linear, therefore after gamma encoding, if any)
387
- if (baton->greyscale) {
388
- image = image.colourspace(VIPS_INTERPRETATION_B_W);
389
- }
390
-
391
- bool const shouldResize = hshrink != 1.0 || vshrink != 1.0;
392
- bool const shouldBlur = baton->blurSigma != 0.0;
393
- bool const shouldConv = baton->convKernelWidth * baton->convKernelHeight > 0;
394
- bool const shouldSharpen = baton->sharpenSigma != 0.0;
395
- bool const shouldComposite = !baton->composite.empty();
396
-
397
- if (shouldComposite && !image.has_alpha()) {
398
- image = sharp::EnsureAlpha(image, 1);
399
- }
400
-
401
- VipsBandFormat premultiplyFormat = image.format();
402
- bool const shouldPremultiplyAlpha = image.has_alpha() &&
403
- (shouldResize || shouldBlur || shouldConv || shouldSharpen);
404
-
405
- if (shouldPremultiplyAlpha) {
406
- image = image.premultiply().cast(premultiplyFormat);
407
- }
408
-
409
- // Resize
410
- if (shouldResize) {
411
- image = image.resize(1.0 / hshrink, VImage::option()
412
- ->set("vscale", 1.0 / vshrink)
413
- ->set("kernel", baton->kernel));
414
- if (baton->keepGainMap) {
415
- gainMap = gainMap.resize(1.0 / hshrink, VImage::option()
416
- ->set("vscale", 1.0 / vshrink)
417
- ->set("kernel", baton->kernel));
418
- }
419
- }
420
-
421
- image = sharp::StaySequential(image,
422
- autoRotation != VIPS_ANGLE_D0 ||
423
- baton->flip ||
424
- rotation != VIPS_ANGLE_D0);
425
- // Auto-rotate post-extract
426
- if (autoRotation != VIPS_ANGLE_D0) {
427
- if (autoRotation != VIPS_ANGLE_D180) {
428
- MultiPageUnsupported(nPages, "Rotate");
429
- }
430
- image = image.rot(autoRotation);
431
- if (baton->keepGainMap) {
432
- gainMap = gainMap.rot(autoRotation);
433
- }
434
- }
435
- // Mirror vertically (up-down) about the x-axis
436
- if (baton->flip) {
437
- image = image.flip(VIPS_DIRECTION_VERTICAL);
438
- if (baton->keepGainMap) {
439
- gainMap = gainMap.flip(VIPS_DIRECTION_VERTICAL);
440
- }
441
- }
442
- // Mirror horizontally (left-right) about the y-axis
443
- if (baton->flop != autoFlop) {
444
- image = image.flip(VIPS_DIRECTION_HORIZONTAL);
445
- if (baton->keepGainMap) {
446
- gainMap = gainMap.flip(VIPS_DIRECTION_HORIZONTAL);
447
- }
448
- }
449
- // Rotate post-extract 90-angle
450
- if (rotation != VIPS_ANGLE_D0) {
451
- if (rotation != VIPS_ANGLE_D180) {
452
- MultiPageUnsupported(nPages, "Rotate");
453
- }
454
- image = image.rot(rotation);
455
- if (baton->keepGainMap) {
456
- gainMap = gainMap.rot(rotation);
457
- }
458
- }
459
-
460
- // Join additional color channels to the image
461
- if (!baton->joinChannelIn.empty()) {
462
- VImage joinImage;
463
- sharp::ImageType joinImageType = sharp::ImageType::UNKNOWN;
464
-
465
- for (unsigned int i = 0; i < baton->joinChannelIn.size(); i++) {
466
- baton->joinChannelIn[i]->access = access;
467
- std::tie(joinImage, joinImageType) = sharp::OpenInput(baton->joinChannelIn[i]);
468
- joinImage = sharp::EnsureColourspace(joinImage, baton->colourspacePipeline);
469
- image = image.bandjoin(joinImage);
470
- }
471
- image = image.copy(VImage::option()->set("interpretation", baton->colourspace));
472
- image = sharp::RemoveGifPalette(image);
473
- }
474
-
475
- inputWidth = image.width();
476
- inputHeight = nPages > 1 ? targetPageHeight : image.height();
477
-
478
- // Resolve dimensions
479
- if (baton->width <= 0) {
480
- baton->width = inputWidth;
481
- }
482
- if (baton->height <= 0) {
483
- baton->height = inputHeight;
484
- }
485
-
486
- // Crop/embed
487
- if (inputWidth != baton->width || inputHeight != baton->height) {
488
- if (baton->canvas == sharp::Canvas::EMBED) {
489
- std::vector<double> background;
490
- std::tie(image, background) = sharp::ApplyAlpha(image, baton->resizeBackground, shouldPremultiplyAlpha);
491
-
492
- // Embed
493
- const auto& [left, top] = sharp::CalculateEmbedPosition(
494
- inputWidth, inputHeight, baton->width, baton->height, baton->position);
495
- const int width = std::max(inputWidth, baton->width);
496
- const int height = std::max(inputHeight, baton->height);
497
-
498
- image = nPages > 1
499
- ? sharp::EmbedMultiPage(image,
500
- left, top, width, height, VIPS_EXTEND_BACKGROUND, background, nPages, &targetPageHeight)
501
- : image.embed(left, top, width, height, VImage::option()
502
- ->set("extend", VIPS_EXTEND_BACKGROUND)
503
- ->set("background", background));
504
- if (baton->keepGainMap) {
505
- gainMap = gainMap.embed(left / gainMapScaleFactor, top / gainMapScaleFactor,
506
- width / gainMapScaleFactor, height / gainMapScaleFactor, VImage::option()
507
- ->set("extend", VIPS_EXTEND_BACKGROUND)
508
- ->set("background", 0));
509
- }
510
- } else if (baton->canvas == sharp::Canvas::CROP) {
511
- if (baton->width > inputWidth) {
512
- baton->width = inputWidth;
513
- }
514
- if (baton->height > inputHeight) {
515
- baton->height = inputHeight;
516
- }
517
-
518
- // Crop
519
- if (baton->position < 9) {
520
- // Gravity-based crop
521
- const auto& [left, top] = sharp::CalculateCrop(
522
- inputWidth, inputHeight, baton->width, baton->height, baton->position);
523
- const int width = std::min(inputWidth, baton->width);
524
- const int height = std::min(inputHeight, baton->height);
525
-
526
- image = nPages > 1
527
- ? sharp::CropMultiPage(image,
528
- left, top, width, height, nPages, &targetPageHeight)
529
- : image.extract_area(left, top, width, height);
530
- if (baton->keepGainMap) {
531
- gainMap = gainMap.extract_area(left / gainMapScaleFactor, top / gainMapScaleFactor,
532
- width / gainMapScaleFactor, height / gainMapScaleFactor);
533
- }
534
- } else {
535
- int attention_x;
536
- int attention_y;
537
-
538
- // Attention-based or Entropy-based crop
539
- MultiPageUnsupported(nPages, "Resize strategy");
540
- KeepGainMapUnsupported(baton->keepGainMap, "Resize strategy");
541
- image = sharp::StaySequential(image);
542
- image = image.smartcrop(baton->width, baton->height, VImage::option()
543
- ->set("interesting", baton->position == 16 ? VIPS_INTERESTING_ENTROPY : VIPS_INTERESTING_ATTENTION)
544
- ->set("premultiplied", shouldPremultiplyAlpha)
545
- ->set("attention_x", &attention_x)
546
- ->set("attention_y", &attention_y));
547
- baton->hasCropOffset = true;
548
- baton->cropOffsetLeft = static_cast<int>(image.xoffset());
549
- baton->cropOffsetTop = static_cast<int>(image.yoffset());
550
- baton->hasAttentionCenter = true;
551
- baton->attentionX = static_cast<int>(attention_x * jpegShrinkOnLoad / scale);
552
- baton->attentionY = static_cast<int>(attention_y * jpegShrinkOnLoad / scale);
553
- }
554
- }
555
- }
556
-
557
- // Rotate post-extract non-90 angle
558
- if (!baton->rotateBefore && baton->rotationAngle != 0.0) {
559
- MultiPageUnsupported(nPages, "Rotate");
560
- image = sharp::StaySequential(image);
561
- std::vector<double> background;
562
- std::tie(image, background) = sharp::ApplyAlpha(image, baton->rotationBackground, shouldPremultiplyAlpha);
563
- image = image.rotate(baton->rotationAngle, VImage::option()->set("background", background));
564
- if (baton->keepGainMap) {
565
- gainMap = gainMap.rotate(baton->rotationAngle, VImage::option()->set("background", 0));
566
- }
567
- }
568
-
569
- // Post extraction
570
- if (baton->topOffsetPost != -1) {
571
- if (nPages > 1) {
572
- image = sharp::CropMultiPage(image,
573
- baton->leftOffsetPost, baton->topOffsetPost, baton->widthPost, baton->heightPost,
574
- nPages, &targetPageHeight);
575
- // heightPost is used in the info object, so update to reflect the number of pages
576
- baton->heightPost *= nPages;
577
- } else {
578
- image = image.extract_area(
579
- baton->leftOffsetPost, baton->topOffsetPost, baton->widthPost, baton->heightPost);
580
- if (baton->keepGainMap) {
581
- gainMap = gainMap.extract_area(baton->leftOffsetPost / gainMapScaleFactor,
582
- baton->topOffsetPost / gainMapScaleFactor, baton->widthPost / gainMapScaleFactor,
583
- baton->heightPost / gainMapScaleFactor);
584
- }
585
- }
586
- }
587
-
588
- // Affine transform
589
- if (!baton->affineMatrix.empty()) {
590
- MultiPageUnsupported(nPages, "Affine");
591
- KeepGainMapUnsupported(baton->keepGainMap, "Affine");
592
- image = sharp::StaySequential(image);
593
- std::vector<double> background;
594
- std::tie(image, background) = sharp::ApplyAlpha(image, baton->affineBackground, shouldPremultiplyAlpha);
595
- vips::VInterpolate interp = vips::VInterpolate::new_from_name(
596
- const_cast<char*>(baton->affineInterpolator.data()));
597
- image = image.affine(baton->affineMatrix, VImage::option()->set("background", background)
598
- ->set("idx", baton->affineIdx)
599
- ->set("idy", baton->affineIdy)
600
- ->set("odx", baton->affineOdx)
601
- ->set("ody", baton->affineOdy)
602
- ->set("interpolate", interp));
603
- }
604
-
605
- // Extend edges
606
- if (baton->extendTop > 0 || baton->extendBottom > 0 || baton->extendLeft > 0 || baton->extendRight > 0) {
607
- // Embed
608
- baton->width = image.width() + baton->extendLeft + baton->extendRight;
609
- baton->height = (nPages > 1 ? targetPageHeight : image.height()) + baton->extendTop + baton->extendBottom;
610
-
611
- std::vector<double> background;
612
- if (baton->extendWith == VIPS_EXTEND_BACKGROUND) {
613
- std::tie(image, background) = sharp::ApplyAlpha(image, baton->extendBackground, shouldPremultiplyAlpha);
614
- }
615
- image = sharp::StaySequential(image, nPages > 1 || baton->extendWith != VIPS_EXTEND_BACKGROUND);
616
- auto options = VImage::option()->set("extend", baton->extendWith);
617
- if (baton->extendWith == VIPS_EXTEND_BACKGROUND) {
618
- options->set("background", background);
619
- }
620
- image = nPages > 1
621
- ? sharp::EmbedMultiPage(image,
622
- baton->extendLeft, baton->extendTop, baton->width, baton->height,
623
- baton->extendWith, background, nPages, &targetPageHeight)
624
- : image.embed(baton->extendLeft, baton->extendTop, baton->width, baton->height, options);
625
- if (baton->keepGainMap) {
626
- gainMap = gainMap.embed(baton->extendLeft / gainMapScaleFactor, baton->extendTop / gainMapScaleFactor,
627
- baton->width / gainMapScaleFactor, baton->height / gainMapScaleFactor, VImage::option()
628
- ->set("extend", baton->extendWith)
629
- ->set("background", 0));
630
- }
631
- }
632
- // Median - must happen before blurring, due to the utility of blurring after thresholding
633
- if (baton->medianSize > 0) {
634
- image = image.median(baton->medianSize);
635
- }
636
-
637
- // Threshold - must happen before blurring, due to the utility of blurring after thresholding
638
- // Threshold - must happen before unflatten to enable non-white unflattening
639
- if (baton->threshold != 0) {
640
- image = sharp::Threshold(image, baton->threshold, baton->thresholdGrayscale);
641
- }
642
-
643
- // Dilate - must happen before blurring, due to the utility of dilating after thresholding
644
- if (baton->dilateWidth != 0) {
645
- image = sharp::Dilate(image, baton->dilateWidth);
646
- }
647
-
648
- // Erode - must happen before blurring, due to the utility of eroding after thresholding
649
- if (baton->erodeWidth != 0) {
650
- image = sharp::Erode(image, baton->erodeWidth);
651
- }
652
-
653
- // Blur
654
- if (shouldBlur) {
655
- image = sharp::Blur(image, baton->blurSigma, baton->precision, baton->minAmpl);
656
- if (baton->keepGainMap) {
657
- gainMap = sharp::Blur(gainMap, baton->blurSigma, baton->precision, baton->minAmpl);
658
- }
659
- }
660
-
661
- // Unflatten the image
662
- if (baton->unflatten) {
663
- image = sharp::Unflatten(image);
664
- }
665
-
666
- // Convolve
667
- if (shouldConv) {
668
- KeepGainMapUnsupported(baton->keepGainMap, "Convolve");
669
- image = sharp::Convolve(image,
670
- baton->convKernelWidth, baton->convKernelHeight,
671
- baton->convKernelScale, baton->convKernelOffset,
672
- baton->convKernel);
673
- }
674
-
675
- // Recomb
676
- if (!baton->recombMatrix.empty()) {
677
- KeepGainMapUnsupported(baton->keepGainMap, "Recomb");
678
- image = sharp::Recomb(image, baton->recombMatrix);
679
- }
680
-
681
- // Modulate
682
- if (baton->brightness != 1.0 || baton->saturation != 1.0 || baton->hue != 0.0 || baton->lightness != 0.0) {
683
- KeepGainMapUnsupported(baton->keepGainMap, "Modulate");
684
- image = sharp::Modulate(image, baton->brightness, baton->saturation, baton->hue, baton->lightness);
685
- }
686
-
687
- // Sharpen
688
- if (shouldSharpen) {
689
- image = sharp::Sharpen(image, baton->sharpenSigma, baton->sharpenM1, baton->sharpenM2,
690
- baton->sharpenX1, baton->sharpenY2, baton->sharpenY3);
691
- }
692
-
693
- // Reverse premultiplication after all transformations
694
- if (shouldPremultiplyAlpha) {
695
- image = image.unpremultiply().cast(premultiplyFormat);
696
- }
697
- baton->premultiplied = shouldPremultiplyAlpha;
698
-
699
- // Composite
700
- if (shouldComposite) {
701
- KeepGainMapUnsupported(baton->keepGainMap, "Composite");
702
- std::vector<VImage> images = { image };
703
- std::vector<int> modes, xs, ys;
704
- for (Composite *composite : baton->composite) {
705
- VImage compositeImage;
706
- sharp::ImageType compositeImageType = sharp::ImageType::UNKNOWN;
707
- composite->input->access = access;
708
- std::tie(compositeImage, compositeImageType) = sharp::OpenInput(composite->input);
709
-
710
- if (composite->input->autoOrient) {
711
- // Respect EXIF Orientation
712
- VipsAngle compositeAutoRotation = VIPS_ANGLE_D0;
713
- bool compositeAutoFlop = false;
714
- std::tie(compositeAutoRotation, compositeAutoFlop) =
715
- CalculateExifRotationAndFlop(sharp::ExifOrientation(compositeImage));
716
-
717
- compositeImage = sharp::RemoveExifOrientation(compositeImage);
718
- compositeImage = sharp::StaySequential(compositeImage, compositeAutoRotation != VIPS_ANGLE_D0);
719
-
720
- if (compositeAutoRotation != VIPS_ANGLE_D0) {
721
- compositeImage = compositeImage.rot(compositeAutoRotation);
722
- }
723
- if (compositeAutoFlop) {
724
- compositeImage = compositeImage.flip(VIPS_DIRECTION_HORIZONTAL);
725
- }
726
- }
727
-
728
- // Verify within current dimensions
729
- if (compositeImage.width() > image.width() || compositeImage.height() > image.height()) {
730
- throw std::runtime_error("Image to composite must have same dimensions or smaller");
731
- }
732
- // Check if overlay is tiled
733
- if (composite->tile) {
734
- int across = 0;
735
- int down = 0;
736
- // Use gravity in overlay
737
- if (compositeImage.width() <= image.width()) {
738
- across = static_cast<int>(ceil(static_cast<double>(image.width()) / compositeImage.width()));
739
- // Ensure odd number of tiles across when gravity is centre, north or south
740
- if (composite->gravity == 0 || composite->gravity == 1 || composite->gravity == 3) {
741
- across |= 1;
742
- }
743
- }
744
- if (compositeImage.height() <= image.height()) {
745
- down = static_cast<int>(ceil(static_cast<double>(image.height()) / compositeImage.height()));
746
- // Ensure odd number of tiles down when gravity is centre, east or west
747
- if (composite->gravity == 0 || composite->gravity == 2 || composite->gravity == 4) {
748
- down |= 1;
749
- }
750
- }
751
- if (across != 0 || down != 0) {
752
- int left;
753
- int top;
754
- compositeImage = sharp::StaySequential(compositeImage).replicate(across, down);
755
- if (composite->hasOffset) {
756
- std::tie(left, top) = sharp::CalculateCrop(
757
- compositeImage.width(), compositeImage.height(), image.width(), image.height(),
758
- composite->left, composite->top);
759
- } else {
760
- std::tie(left, top) = sharp::CalculateCrop(
761
- compositeImage.width(), compositeImage.height(), image.width(), image.height(), composite->gravity);
762
- }
763
- compositeImage = compositeImage.extract_area(left, top, image.width(), image.height());
764
- }
765
- // gravity was used for extract_area, set it back to its default value of 0
766
- composite->gravity = 0;
767
- }
768
- // Ensure image to composite is with unpremultiplied alpha
769
- compositeImage = sharp::EnsureAlpha(compositeImage, 1);
770
- if (composite->premultiplied) compositeImage = compositeImage.unpremultiply();
771
- // Calculate position
772
- int left;
773
- int top;
774
- if (composite->hasOffset) {
775
- // Composite image at given offsets
776
- if (composite->tile) {
777
- std::tie(left, top) = sharp::CalculateCrop(image.width(), image.height(),
778
- compositeImage.width(), compositeImage.height(), composite->left, composite->top);
779
- } else {
780
- left = composite->left;
781
- top = composite->top;
782
- }
783
- } else {
784
- // Composite image with given gravity
785
- std::tie(left, top) = sharp::CalculateCrop(image.width(), image.height(),
786
- compositeImage.width(), compositeImage.height(), composite->gravity);
787
- }
788
- images.push_back(compositeImage);
789
- modes.push_back(composite->mode);
790
- xs.push_back(left);
791
- ys.push_back(top);
792
- }
793
- image = VImage::composite(images, modes, VImage::option()
794
- ->set("compositing_space", baton->colourspacePipeline == VIPS_INTERPRETATION_LAST
795
- ? VIPS_INTERPRETATION_sRGB
796
- : baton->colourspacePipeline)
797
- ->set("x", xs)
798
- ->set("y", ys));
799
- image = sharp::RemoveGifPalette(image);
800
- }
801
-
802
- // Gamma decoding (brighten)
803
- if (baton->gammaOut >= 1 && baton->gammaOut <= 3) {
804
- image = sharp::Gamma(image, baton->gammaOut);
805
- }
806
-
807
- // Linear adjustment (a * in + b)
808
- if (!baton->linearA.empty()) {
809
- image = sharp::Linear(image, baton->linearA, baton->linearB);
810
- }
811
-
812
- // Apply normalisation - stretch luminance to cover full dynamic range
813
- if (baton->normalise) {
814
- KeepGainMapUnsupported(baton->keepGainMap, "Normalise");
815
- image = sharp::StaySequential(image);
816
- image = sharp::Normalise(image, baton->normaliseLower, baton->normaliseUpper);
817
- }
818
-
819
- // Apply contrast limiting adaptive histogram equalization (CLAHE)
820
- if (baton->claheWidth != 0 && baton->claheHeight != 0) {
821
- KeepGainMapUnsupported(baton->keepGainMap, "Clahe");
822
- image = sharp::StaySequential(image);
823
- image = sharp::Clahe(image, baton->claheWidth, baton->claheHeight, baton->claheMaxSlope);
824
- }
825
-
826
- // Apply bitwise boolean operation between images
827
- if (baton->boolean != nullptr) {
828
- KeepGainMapUnsupported(baton->keepGainMap, "Boolean");
829
- VImage booleanImage;
830
- sharp::ImageType booleanImageType = sharp::ImageType::UNKNOWN;
831
- baton->boolean->access = access;
832
- std::tie(booleanImage, booleanImageType) = sharp::OpenInput(baton->boolean);
833
- booleanImage = sharp::EnsureColourspace(booleanImage, baton->colourspacePipeline);
834
- image = sharp::Boolean(image, booleanImage, baton->booleanOp);
835
- image = sharp::RemoveGifPalette(image);
836
- }
837
-
838
- // Apply per-channel Bandbool bitwise operations after all other operations
839
- if (baton->bandBoolOp >= VIPS_OPERATION_BOOLEAN_AND && baton->bandBoolOp < VIPS_OPERATION_BOOLEAN_LAST) {
840
- image = sharp::Bandbool(image, baton->bandBoolOp);
841
- }
842
-
843
- // Tint the image
844
- if (baton->tint[0] >= 0.0) {
845
- image = sharp::Tint(image, baton->tint);
846
- }
847
-
848
- // Remove alpha channel, if any
849
- if (baton->removeAlpha) {
850
- image = sharp::RemoveAlpha(image);
851
- }
852
-
853
- // Ensure alpha channel, if missing
854
- if (baton->ensureAlpha != -1) {
855
- image = sharp::EnsureAlpha(image, baton->ensureAlpha);
856
- }
857
-
858
- // Ensure output colour space
859
- if (sharp::Is16Bit(image.interpretation())) {
860
- image = image.cast(VIPS_FORMAT_USHORT);
861
- }
862
- if (image.interpretation() != baton->colourspace) {
863
- image = image.colourspace(baton->colourspace, VImage::option()->set("source_space", image.interpretation()));
864
- if (inputProfile.first != nullptr && baton->withIccProfile.empty()) {
865
- image = sharp::SetProfile(image, inputProfile);
866
- }
867
- }
868
-
869
- // Extract channel
870
- if (baton->extractChannel > -1) {
871
- KeepGainMapUnsupported(baton->keepGainMap, "Extract channel");
872
- if (baton->extractChannel >= image.bands()) {
873
- if (baton->extractChannel == 3 && image.has_alpha()) {
874
- baton->extractChannel = image.bands() - 1;
875
- } else {
876
- (baton->err)
877
- .append("Cannot extract channel ").append(std::to_string(baton->extractChannel))
878
- .append(" from image with channels 0-").append(std::to_string(image.bands() - 1));
879
- return Error();
880
- }
881
- }
882
- VipsInterpretation colourspace = sharp::Is16Bit(image.interpretation())
883
- ? VIPS_INTERPRETATION_GREY16
884
- : VIPS_INTERPRETATION_B_W;
885
- image = image
886
- .extract_band(baton->extractChannel)
887
- .copy(VImage::option()->set("interpretation", colourspace));
888
- }
889
-
890
- // Apply output ICC profile
891
- if (!baton->withIccProfile.empty()) {
892
- try {
893
- image = image.icc_transform(const_cast<char*>(baton->withIccProfile.data()), VImage::option()
894
- ->set("input_profile", processingProfile)
895
- ->set("embedded", true)
896
- ->set("depth", sharp::Is16Bit(image.interpretation()) ? 16 : 8)
897
- ->set("intent", VIPS_INTENT_PERCEPTUAL));
898
- } catch(...) {
899
- sharp::VipsWarningCallback(nullptr, G_LOG_LEVEL_WARNING, "Invalid profile", nullptr);
900
- }
901
- }
902
-
903
- // Negate the colours in the image
904
- if (baton->negate) {
905
- image = sharp::Negate(image, baton->negateAlpha);
906
- if (baton->keepGainMap) {
907
- gainMap = sharp::Negate(gainMap, false);
908
- }
909
- }
910
-
911
- // Override EXIF Orientation tag
912
- if (baton->withMetadataOrientation != -1) {
913
- image = sharp::SetExifOrientation(image, baton->withMetadataOrientation);
914
- }
915
- // Override pixel density
916
- if (baton->withMetadataDensity > 0) {
917
- image = sharp::SetDensity(image, baton->withMetadataDensity);
918
- }
919
- // EXIF key/value pairs
920
- if (baton->keepMetadata & VIPS_FOREIGN_KEEP_EXIF) {
921
- image = image.copy();
922
- if (!baton->withExifMerge) {
923
- image = sharp::RemoveExif(image);
924
- }
925
- for (const auto& [key, value] : baton->withExif) {
926
- image.set(key.c_str(), value.c_str());
927
- }
928
- }
929
- // XMP buffer
930
- if ((baton->keepMetadata & VIPS_FOREIGN_KEEP_XMP) && !baton->withXmp.empty()) {
931
- image = image.copy();
932
- image.set(VIPS_META_XMP_NAME, nullptr,
933
- const_cast<void*>(static_cast<void const*>(baton->withXmp.c_str())), baton->withXmp.size());
934
- }
935
- // Number of channels used in output image
936
- baton->channels = image.bands();
937
- baton->width = image.width();
938
- baton->height = image.height();
939
-
940
- image = sharp::SetAnimationProperties(
941
- image, nPages, targetPageHeight, baton->delay, baton->loop);
942
-
943
- if (image.get_typeof(VIPS_META_PAGE_HEIGHT) == G_TYPE_INT) {
944
- baton->pageHeightOut = image.get_int(VIPS_META_PAGE_HEIGHT);
945
- baton->pagesOut = image.get_int(VIPS_META_N_PAGES);
946
- }
947
- baton->hasAlphaOut = image.has_alpha();
948
-
949
- // Output
950
- sharp::SetTimeout(image, baton->timeoutSeconds);
951
- if (baton->fileOut.empty()) {
952
- // Buffer output
953
- if (baton->formatOut == "jpeg" || (baton->formatOut == "input" && inputImageType == sharp::ImageType::JPEG)) {
954
- // Write JPEG to buffer
955
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::JPEG);
956
- VipsArea *area;
957
- if (baton->keepGainMap) {
958
- image = ReattachGainMap(image, gainMap, baton);
959
- area = reinterpret_cast<VipsArea*>(image.uhdrsave_buffer(VImage::option()
960
- ->set("keep", baton->keepMetadata)
961
- ->set("Q", baton->jpegQuality)
962
- ->set("gainmap_scale_factor", gainMapScaleFactor)));
963
- } else {
964
- area = reinterpret_cast<VipsArea*>(image.jpegsave_buffer(VImage::option()
965
- ->set("keep", baton->keepMetadata)
966
- ->set("Q", baton->jpegQuality)
967
- ->set("interlace", baton->jpegProgressive)
968
- ->set("subsample_mode", baton->jpegChromaSubsampling == "4:4:4"
969
- ? VIPS_FOREIGN_SUBSAMPLE_OFF
970
- : VIPS_FOREIGN_SUBSAMPLE_ON)
971
- ->set("trellis_quant", baton->jpegTrellisQuantisation)
972
- ->set("quant_table", baton->jpegQuantisationTable)
973
- ->set("overshoot_deringing", baton->jpegOvershootDeringing)
974
- ->set("optimize_scans", baton->jpegOptimiseScans)
975
- ->set("optimize_coding", baton->jpegOptimiseCoding)));
976
- }
977
- baton->bufferOut = static_cast<char*>(area->data);
978
- baton->bufferOutLength = area->length;
979
- area->free_fn = nullptr;
980
- vips_area_unref(area);
981
- baton->formatOut = "jpeg";
982
- if (baton->colourspace == VIPS_INTERPRETATION_CMYK) {
983
- baton->channels = std::min(baton->channels, 4);
984
- } else {
985
- baton->channels = std::min(baton->channels, 3);
986
- }
987
- baton->hasAlphaOut = false;
988
- } else if (baton->formatOut == "jp2" || (baton->formatOut == "input"
989
- && inputImageType == sharp::ImageType::JP2)) {
990
- // Write JP2 to Buffer
991
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::JP2);
992
- VipsArea *area = reinterpret_cast<VipsArea*>(image.jp2ksave_buffer(VImage::option()
993
- ->set("Q", baton->jp2Quality)
994
- ->set("lossless", baton->jp2Lossless)
995
- ->set("subsample_mode", baton->jp2ChromaSubsampling == "4:4:4"
996
- ? VIPS_FOREIGN_SUBSAMPLE_OFF : VIPS_FOREIGN_SUBSAMPLE_ON)
997
- ->set("tile_height", baton->jp2TileHeight)
998
- ->set("tile_width", baton->jp2TileWidth)));
999
- baton->bufferOut = static_cast<char*>(area->data);
1000
- baton->bufferOutLength = area->length;
1001
- area->free_fn = nullptr;
1002
- vips_area_unref(area);
1003
- baton->formatOut = "jp2";
1004
- } else if (baton->formatOut == "png" || (baton->formatOut == "input" &&
1005
- (inputImageType == sharp::ImageType::PNG || inputImageType == sharp::ImageType::SVG))) {
1006
- // Write PNG to buffer
1007
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::PNG);
1008
- VipsArea *area = reinterpret_cast<VipsArea*>(image.pngsave_buffer(VImage::option()
1009
- ->set("keep", baton->keepMetadata)
1010
- ->set("interlace", baton->pngProgressive)
1011
- ->set("compression", baton->pngCompressionLevel)
1012
- ->set("filter", baton->pngAdaptiveFiltering ? VIPS_FOREIGN_PNG_FILTER_ALL : VIPS_FOREIGN_PNG_FILTER_NONE)
1013
- ->set("palette", baton->pngPalette)
1014
- ->set("Q", baton->pngQuality)
1015
- ->set("effort", baton->pngEffort)
1016
- ->set("bitdepth", sharp::Is16Bit(image.interpretation()) ? 16 : baton->pngBitdepth)
1017
- ->set("dither", baton->pngDither)));
1018
- baton->bufferOut = static_cast<char*>(area->data);
1019
- baton->bufferOutLength = area->length;
1020
- area->free_fn = nullptr;
1021
- vips_area_unref(area);
1022
- baton->formatOut = "png";
1023
- } else if (baton->formatOut == "webp" ||
1024
- (baton->formatOut == "input" && inputImageType == sharp::ImageType::WEBP)) {
1025
- // Write WEBP to buffer
1026
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::WEBP);
1027
- VipsArea *area = reinterpret_cast<VipsArea*>(image.webpsave_buffer(VImage::option()
1028
- ->set("keep", baton->keepMetadata)
1029
- ->set("Q", baton->webpQuality)
1030
- ->set("lossless", baton->webpLossless)
1031
- ->set("near_lossless", baton->webpNearLossless)
1032
- ->set("smart_subsample", baton->webpSmartSubsample)
1033
- ->set("smart_deblock", baton->webpSmartDeblock)
1034
- ->set("preset", baton->webpPreset)
1035
- ->set("effort", baton->webpEffort)
1036
- ->set("min_size", baton->webpMinSize)
1037
- ->set("mixed", baton->webpMixed)
1038
- ->set("exact", baton->webpExact)
1039
- ->set("alpha_q", baton->webpAlphaQuality)));
1040
- baton->bufferOut = static_cast<char*>(area->data);
1041
- baton->bufferOutLength = area->length;
1042
- area->free_fn = nullptr;
1043
- vips_area_unref(area);
1044
- baton->formatOut = "webp";
1045
- } else if (baton->formatOut == "gif" ||
1046
- (baton->formatOut == "input" && inputImageType == sharp::ImageType::GIF)) {
1047
- // Write GIF to buffer
1048
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::GIF);
1049
- VipsArea *area = reinterpret_cast<VipsArea*>(image.gifsave_buffer(VImage::option()
1050
- ->set("keep", baton->keepMetadata)
1051
- ->set("bitdepth", baton->gifBitdepth)
1052
- ->set("effort", baton->gifEffort)
1053
- ->set("reuse", baton->gifReuse)
1054
- ->set("interlace", baton->gifProgressive)
1055
- ->set("interframe_maxerror", baton->gifInterFrameMaxError)
1056
- ->set("interpalette_maxerror", baton->gifInterPaletteMaxError)
1057
- ->set("keep_duplicate_frames", baton->gifKeepDuplicateFrames)
1058
- ->set("dither", baton->gifDither)));
1059
- baton->bufferOut = static_cast<char*>(area->data);
1060
- baton->bufferOutLength = area->length;
1061
- area->free_fn = nullptr;
1062
- vips_area_unref(area);
1063
- baton->formatOut = "gif";
1064
- } else if (baton->formatOut == "tiff" ||
1065
- (baton->formatOut == "input" && inputImageType == sharp::ImageType::TIFF)) {
1066
- // Write TIFF to buffer
1067
- if (baton->tiffCompression == VIPS_FOREIGN_TIFF_COMPRESSION_JPEG) {
1068
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::JPEG);
1069
- baton->channels = std::min(baton->channels, 3);
1070
- baton->hasAlphaOut = false;
1071
- }
1072
- // Cast pixel values to float, if required
1073
- if (baton->tiffPredictor == VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT) {
1074
- image = image.cast(VIPS_FORMAT_FLOAT);
1075
- }
1076
- VipsArea *area = reinterpret_cast<VipsArea*>(image.tiffsave_buffer(VImage::option()
1077
- ->set("keep", baton->keepMetadata)
1078
- ->set("Q", baton->tiffQuality)
1079
- ->set("bitdepth", baton->tiffBitdepth)
1080
- ->set("compression", baton->tiffCompression)
1081
- ->set("bigtiff", baton->tiffBigtiff)
1082
- ->set("miniswhite", baton->tiffMiniswhite)
1083
- ->set("predictor", baton->tiffPredictor)
1084
- ->set("pyramid", baton->tiffPyramid)
1085
- ->set("tile", baton->tiffTile)
1086
- ->set("tile_height", baton->tiffTileHeight)
1087
- ->set("tile_width", baton->tiffTileWidth)
1088
- ->set("xres", baton->tiffXres)
1089
- ->set("yres", baton->tiffYres)
1090
- ->set("resunit", baton->tiffResolutionUnit)));
1091
- baton->bufferOut = static_cast<char*>(area->data);
1092
- baton->bufferOutLength = area->length;
1093
- area->free_fn = nullptr;
1094
- vips_area_unref(area);
1095
- baton->formatOut = "tiff";
1096
- } else if (baton->formatOut == "heif" ||
1097
- (baton->formatOut == "input" && inputImageType == sharp::ImageType::HEIF)) {
1098
- // Write HEIF to buffer
1099
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::HEIF);
1100
- image = sharp::RemoveAnimationProperties(image);
1101
- VipsArea *area = reinterpret_cast<VipsArea*>(image.heifsave_buffer(VImage::option()
1102
- ->set("keep", baton->keepMetadata)
1103
- ->set("Q", baton->heifQuality)
1104
- ->set("compression", baton->heifCompression)
1105
- ->set("effort", baton->heifEffort)
1106
- ->set("bitdepth", baton->heifBitdepth)
1107
- ->set("tune", baton->heifTune.c_str())
1108
- ->set("subsample_mode", baton->heifChromaSubsampling == "4:4:4"
1109
- ? VIPS_FOREIGN_SUBSAMPLE_OFF : VIPS_FOREIGN_SUBSAMPLE_ON)
1110
- ->set("lossless", baton->heifLossless)));
1111
- baton->bufferOut = static_cast<char*>(area->data);
1112
- baton->bufferOutLength = area->length;
1113
- area->free_fn = nullptr;
1114
- vips_area_unref(area);
1115
- baton->formatOut = "heif";
1116
- } else if (baton->formatOut == "dz") {
1117
- // Write DZ to buffer
1118
- baton->tileContainer = VIPS_FOREIGN_DZ_CONTAINER_ZIP;
1119
- if (!image.has_alpha()) {
1120
- baton->tileBackground.pop_back();
1121
- }
1122
- image = sharp::StaySequential(image, baton->tileAngle != 0);
1123
- vips::VOption *options = BuildOptionsDZ(baton);
1124
- VipsArea *area = reinterpret_cast<VipsArea*>(image.dzsave_buffer(options));
1125
- baton->bufferOut = static_cast<char*>(area->data);
1126
- baton->bufferOutLength = area->length;
1127
- area->free_fn = nullptr;
1128
- vips_area_unref(area);
1129
- baton->formatOut = "dz";
1130
- if (baton->tileFormat == "jpeg") {
1131
- baton->hasAlphaOut = false;
1132
- }
1133
- } else if (baton->formatOut == "jxl" ||
1134
- (baton->formatOut == "input" && inputImageType == sharp::ImageType::JXL)) {
1135
- // Write JXL to buffer
1136
- image = sharp::RemoveAnimationProperties(image);
1137
- VipsArea *area = reinterpret_cast<VipsArea*>(image.jxlsave_buffer(VImage::option()
1138
- ->set("keep", baton->keepMetadata)
1139
- ->set("distance", baton->jxlDistance)
1140
- ->set("tier", baton->jxlDecodingTier)
1141
- ->set("effort", baton->jxlEffort)
1142
- ->set("lossless", baton->jxlLossless)));
1143
- baton->bufferOut = static_cast<char*>(area->data);
1144
- baton->bufferOutLength = area->length;
1145
- area->free_fn = nullptr;
1146
- vips_area_unref(area);
1147
- baton->formatOut = "jxl";
1148
- } else if (baton->formatOut == "raw" ||
1149
- (baton->formatOut == "input" && inputImageType == sharp::ImageType::RAW)) {
1150
- // Write raw, uncompressed image data to buffer
1151
- if (baton->greyscale || image.interpretation() == VIPS_INTERPRETATION_B_W) {
1152
- // Extract first band for greyscale image
1153
- image = image[0];
1154
- baton->channels = 1;
1155
- }
1156
- if (image.format() != baton->rawDepth) {
1157
- // Cast pixels to requested format
1158
- image = image.cast(baton->rawDepth);
1159
- }
1160
- // Get raw image data
1161
- baton->bufferOut = static_cast<char*>(image.write_to_memory(&baton->bufferOutLength));
1162
- if (baton->bufferOut == nullptr) {
1163
- throw std::runtime_error("Could not allocate enough memory for raw output");
1164
- }
1165
- baton->formatOut = "raw";
1166
- } else {
1167
- // Unsupported output format
1168
- auto unsupported = std::string("Unsupported output format ");
1169
- if (baton->formatOut == "input") {
1170
- unsupported.append("when trying to match input format of ");
1171
- unsupported.append(ImageTypeId(inputImageType));
1172
- } else {
1173
- unsupported.append(baton->formatOut);
1174
- }
1175
- throw std::runtime_error(unsupported);
1176
- }
1177
- } else {
1178
- // File output
1179
- bool const isJpeg = sharp::IsJpeg(baton->fileOut);
1180
- bool const isPng = sharp::IsPng(baton->fileOut);
1181
- bool const isWebp = sharp::IsWebp(baton->fileOut);
1182
- bool const isGif = sharp::IsGif(baton->fileOut);
1183
- bool const isTiff = sharp::IsTiff(baton->fileOut);
1184
- bool const isJp2 = sharp::IsJp2(baton->fileOut);
1185
- bool const isHeif = sharp::IsHeif(baton->fileOut);
1186
- bool const isJxl = sharp::IsJxl(baton->fileOut);
1187
- bool const isDz = sharp::IsDz(baton->fileOut);
1188
- bool const isDzZip = sharp::IsDzZip(baton->fileOut);
1189
- bool const isV = sharp::IsV(baton->fileOut);
1190
- bool const mightMatchInput = baton->formatOut == "input";
1191
- bool const willMatchInput = mightMatchInput &&
1192
- !(isJpeg || isPng || isWebp || isGif || isTiff || isJp2 || isHeif || isDz || isDzZip || isV);
1193
-
1194
- if (baton->formatOut == "jpeg" || (mightMatchInput && isJpeg) ||
1195
- (willMatchInput && inputImageType == sharp::ImageType::JPEG)) {
1196
- // Write JPEG to file
1197
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::JPEG);
1198
- if (baton->keepGainMap) {
1199
- image = ReattachGainMap(image, gainMap, baton);
1200
- image.uhdrsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1201
- ->set("keep", baton->keepMetadata)
1202
- ->set("Q", baton->jpegQuality)
1203
- ->set("gainmap_scale_factor", gainMapScaleFactor));
1204
- } else {
1205
- image.jpegsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1206
- ->set("keep", baton->keepMetadata)
1207
- ->set("Q", baton->jpegQuality)
1208
- ->set("interlace", baton->jpegProgressive)
1209
- ->set("subsample_mode", baton->jpegChromaSubsampling == "4:4:4"
1210
- ? VIPS_FOREIGN_SUBSAMPLE_OFF
1211
- : VIPS_FOREIGN_SUBSAMPLE_ON)
1212
- ->set("trellis_quant", baton->jpegTrellisQuantisation)
1213
- ->set("quant_table", baton->jpegQuantisationTable)
1214
- ->set("overshoot_deringing", baton->jpegOvershootDeringing)
1215
- ->set("optimize_scans", baton->jpegOptimiseScans)
1216
- ->set("optimize_coding", baton->jpegOptimiseCoding));
1217
- }
1218
- baton->formatOut = "jpeg";
1219
- baton->channels = std::min(baton->channels, 3);
1220
- baton->hasAlphaOut = false;
1221
- } else if (baton->formatOut == "jp2" || (mightMatchInput && isJp2) ||
1222
- (willMatchInput && (inputImageType == sharp::ImageType::JP2))) {
1223
- // Write JP2 to file
1224
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::JP2);
1225
- image.jp2ksave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1226
- ->set("Q", baton->jp2Quality)
1227
- ->set("lossless", baton->jp2Lossless)
1228
- ->set("subsample_mode", baton->jp2ChromaSubsampling == "4:4:4"
1229
- ? VIPS_FOREIGN_SUBSAMPLE_OFF : VIPS_FOREIGN_SUBSAMPLE_ON)
1230
- ->set("tile_height", baton->jp2TileHeight)
1231
- ->set("tile_width", baton->jp2TileWidth));
1232
- baton->formatOut = "jp2";
1233
- } else if (baton->formatOut == "png" || (mightMatchInput && isPng) || (willMatchInput &&
1234
- (inputImageType == sharp::ImageType::PNG || inputImageType == sharp::ImageType::SVG))) {
1235
- // Write PNG to file
1236
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::PNG);
1237
- image.pngsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1238
- ->set("keep", baton->keepMetadata)
1239
- ->set("interlace", baton->pngProgressive)
1240
- ->set("compression", baton->pngCompressionLevel)
1241
- ->set("filter", baton->pngAdaptiveFiltering ? VIPS_FOREIGN_PNG_FILTER_ALL : VIPS_FOREIGN_PNG_FILTER_NONE)
1242
- ->set("palette", baton->pngPalette)
1243
- ->set("Q", baton->pngQuality)
1244
- ->set("bitdepth", sharp::Is16Bit(image.interpretation()) ? 16 : baton->pngBitdepth)
1245
- ->set("effort", baton->pngEffort)
1246
- ->set("dither", baton->pngDither));
1247
- baton->formatOut = "png";
1248
- } else if (baton->formatOut == "webp" || (mightMatchInput && isWebp) ||
1249
- (willMatchInput && inputImageType == sharp::ImageType::WEBP)) {
1250
- // Write WEBP to file
1251
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::WEBP);
1252
- image.webpsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1253
- ->set("keep", baton->keepMetadata)
1254
- ->set("Q", baton->webpQuality)
1255
- ->set("lossless", baton->webpLossless)
1256
- ->set("near_lossless", baton->webpNearLossless)
1257
- ->set("smart_subsample", baton->webpSmartSubsample)
1258
- ->set("smart_deblock", baton->webpSmartDeblock)
1259
- ->set("preset", baton->webpPreset)
1260
- ->set("effort", baton->webpEffort)
1261
- ->set("min_size", baton->webpMinSize)
1262
- ->set("mixed", baton->webpMixed)
1263
- ->set("exact", baton->webpExact)
1264
- ->set("alpha_q", baton->webpAlphaQuality));
1265
- baton->formatOut = "webp";
1266
- } else if (baton->formatOut == "gif" || (mightMatchInput && isGif) ||
1267
- (willMatchInput && inputImageType == sharp::ImageType::GIF)) {
1268
- // Write GIF to file
1269
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::GIF);
1270
- image.gifsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1271
- ->set("keep", baton->keepMetadata)
1272
- ->set("bitdepth", baton->gifBitdepth)
1273
- ->set("effort", baton->gifEffort)
1274
- ->set("reuse", baton->gifReuse)
1275
- ->set("interlace", baton->gifProgressive)
1276
- ->set("interframe_maxerror", baton->gifInterFrameMaxError)
1277
- ->set("interpalette_maxerror", baton->gifInterPaletteMaxError)
1278
- ->set("keep_duplicate_frames", baton->gifKeepDuplicateFrames)
1279
- ->set("dither", baton->gifDither));
1280
- baton->formatOut = "gif";
1281
- } else if (baton->formatOut == "tiff" || (mightMatchInput && isTiff) ||
1282
- (willMatchInput && inputImageType == sharp::ImageType::TIFF)) {
1283
- // Write TIFF to file
1284
- if (baton->tiffCompression == VIPS_FOREIGN_TIFF_COMPRESSION_JPEG) {
1285
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::JPEG);
1286
- baton->channels = std::min(baton->channels, 3);
1287
- baton->hasAlphaOut = false;
1288
- }
1289
- // Cast pixel values to float, if required
1290
- if (baton->tiffPredictor == VIPS_FOREIGN_TIFF_PREDICTOR_FLOAT) {
1291
- image = image.cast(VIPS_FORMAT_FLOAT);
1292
- }
1293
- image.tiffsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1294
- ->set("keep", baton->keepMetadata)
1295
- ->set("Q", baton->tiffQuality)
1296
- ->set("bitdepth", baton->tiffBitdepth)
1297
- ->set("compression", baton->tiffCompression)
1298
- ->set("bigtiff", baton->tiffBigtiff)
1299
- ->set("miniswhite", baton->tiffMiniswhite)
1300
- ->set("predictor", baton->tiffPredictor)
1301
- ->set("pyramid", baton->tiffPyramid)
1302
- ->set("tile", baton->tiffTile)
1303
- ->set("tile_height", baton->tiffTileHeight)
1304
- ->set("tile_width", baton->tiffTileWidth)
1305
- ->set("xres", baton->tiffXres)
1306
- ->set("yres", baton->tiffYres)
1307
- ->set("resunit", baton->tiffResolutionUnit));
1308
- baton->formatOut = "tiff";
1309
- } else if (baton->formatOut == "heif" || (mightMatchInput && isHeif) ||
1310
- (willMatchInput && inputImageType == sharp::ImageType::HEIF)) {
1311
- // Write HEIF to file
1312
- sharp::AssertImageTypeDimensions(image, sharp::ImageType::HEIF);
1313
- image = sharp::RemoveAnimationProperties(image);
1314
- image.heifsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1315
- ->set("keep", baton->keepMetadata)
1316
- ->set("Q", baton->heifQuality)
1317
- ->set("compression", baton->heifCompression)
1318
- ->set("effort", baton->heifEffort)
1319
- ->set("bitdepth", baton->heifBitdepth)
1320
- ->set("tune", baton->heifTune.c_str())
1321
- ->set("subsample_mode", baton->heifChromaSubsampling == "4:4:4"
1322
- ? VIPS_FOREIGN_SUBSAMPLE_OFF : VIPS_FOREIGN_SUBSAMPLE_ON)
1323
- ->set("lossless", baton->heifLossless));
1324
- baton->formatOut = "heif";
1325
- } else if (baton->formatOut == "jxl" || (mightMatchInput && isJxl) ||
1326
- (willMatchInput && inputImageType == sharp::ImageType::JXL)) {
1327
- // Write JXL to file
1328
- image = sharp::RemoveAnimationProperties(image);
1329
- image.jxlsave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1330
- ->set("keep", baton->keepMetadata)
1331
- ->set("distance", baton->jxlDistance)
1332
- ->set("tier", baton->jxlDecodingTier)
1333
- ->set("effort", baton->jxlEffort)
1334
- ->set("lossless", baton->jxlLossless));
1335
- baton->formatOut = "jxl";
1336
- } else if (baton->formatOut == "dz" || isDz || isDzZip) {
1337
- // Write DZ to file
1338
- if (isDzZip) {
1339
- baton->tileContainer = VIPS_FOREIGN_DZ_CONTAINER_ZIP;
1340
- }
1341
- if (!image.has_alpha()) {
1342
- baton->tileBackground.pop_back();
1343
- }
1344
- image = sharp::StaySequential(image, baton->tileAngle != 0);
1345
- vips::VOption *options = BuildOptionsDZ(baton);
1346
- image.dzsave(const_cast<char*>(baton->fileOut.data()), options);
1347
- baton->formatOut = "dz";
1348
- if (baton->tileFormat == "jpeg") {
1349
- baton->hasAlphaOut = false;
1350
- }
1351
- } else if (baton->formatOut == "v" || (mightMatchInput && isV) ||
1352
- (willMatchInput && inputImageType == sharp::ImageType::VIPS)) {
1353
- // Write V to file
1354
- image.vipssave(const_cast<char*>(baton->fileOut.data()), VImage::option()
1355
- ->set("keep", baton->keepMetadata));
1356
- baton->formatOut = "v";
1357
- } else {
1358
- // Unsupported output format
1359
- (baton->err).append("Unsupported output format " + baton->fileOut);
1360
- return Error();
1361
- }
1362
- }
1363
- } catch (std::runtime_error const &err) {
1364
- char const *what = err.what();
1365
- if (what && what[0]) {
1366
- (baton->err).append(what);
1367
- } else {
1368
- if (baton->input->failOn == VIPS_FAIL_ON_WARNING) {
1369
- (baton->err).append("Warning treated as error due to failOn setting");
1370
- baton->errUseWarning = true;
1371
- } else {
1372
- (baton->err).append("Unknown error");
1373
- }
1374
- }
1375
- }
1376
- // Clean up libvips' per-request data and threads
1377
- vips_error_clear();
1378
- vips_thread_shutdown();
1379
- }
1380
-
1381
- void OnOK() {
1382
- Napi::Env env = Env();
1383
- Napi::HandleScope scope(env);
1384
-
1385
- // Handle warnings
1386
- std::string warning = sharp::VipsWarningPop();
1387
- while (!warning.empty()) {
1388
- if (baton->errUseWarning) {
1389
- (baton->err).append("\n").append(warning);
1390
- } else {
1391
- debuglog.SHARP_CALLBACK_FN_NAME(Receiver().Value(), { Napi::String::New(env, warning) });
1392
- }
1393
- warning = sharp::VipsWarningPop();
1394
- }
1395
- if (baton->err.empty()) {
1396
- int width = baton->width;
1397
- int height = baton->height;
1398
- if (baton->topOffsetPre != -1 && (baton->width == -1 || baton->height == -1)) {
1399
- width = baton->widthPre;
1400
- height = baton->heightPre;
1401
- }
1402
- if (baton->topOffsetPost != -1) {
1403
- width = baton->widthPost;
1404
- height = baton->heightPost;
1405
- }
1406
- // Info Object
1407
- Napi::Object info = Napi::Object::New(env);
1408
- info.Set("format", baton->formatOut);
1409
- info.Set("width", static_cast<uint32_t>(width));
1410
- info.Set("height", static_cast<uint32_t>(height));
1411
- info.Set("channels", static_cast<uint32_t>(baton->channels));
1412
- if (baton->formatOut == "raw") {
1413
- info.Set("depth", vips_enum_nick(VIPS_TYPE_BAND_FORMAT, baton->rawDepth));
1414
- }
1415
- info.Set("premultiplied", baton->premultiplied);
1416
- if (baton->hasCropOffset) {
1417
- info.Set("cropOffsetLeft", static_cast<int32_t>(baton->cropOffsetLeft));
1418
- info.Set("cropOffsetTop", static_cast<int32_t>(baton->cropOffsetTop));
1419
- }
1420
- if (baton->hasAttentionCenter) {
1421
- info.Set("attentionX", static_cast<int32_t>(baton->attentionX));
1422
- info.Set("attentionY", static_cast<int32_t>(baton->attentionY));
1423
- }
1424
- if (baton->trimThreshold >= 0.0) {
1425
- info.Set("trimOffsetLeft", static_cast<int32_t>(baton->trimOffsetLeft));
1426
- info.Set("trimOffsetTop", static_cast<int32_t>(baton->trimOffsetTop));
1427
- }
1428
- if (baton->input->textAutofitDpi) {
1429
- info.Set("textAutofitDpi", static_cast<uint32_t>(baton->input->textAutofitDpi));
1430
- }
1431
- if (baton->pageHeightOut) {
1432
- info.Set("pageHeight", static_cast<int32_t>(baton->pageHeightOut));
1433
- info.Set("pages", static_cast<int32_t>(baton->pagesOut));
1434
- }
1435
- info.Set("hasAlpha", baton->hasAlphaOut);
1436
-
1437
- if (baton->bufferOutLength > 0) {
1438
- info.Set("size", static_cast<uint32_t>(baton->bufferOutLength));
1439
- if (baton->typedArrayOut) {
1440
- // ECMAScript ArrayBuffer with Uint8Array view
1441
- Napi::TypedArrayOf<uint8_t> data = Napi::Buffer<char>::Copy(env,
1442
- static_cast<char*>(baton->bufferOut), baton->bufferOutLength);
1443
- sharp::FreeCallback(static_cast<char*>(baton->bufferOut), nullptr);
1444
- Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(), { env.Null(), data, info });
1445
- } else {
1446
- // Node.js Buffer
1447
- Napi::Buffer<char> data = Napi::Buffer<char>::NewOrCopy(env, static_cast<char*>(baton->bufferOut),
1448
- baton->bufferOutLength, sharp::FreeCallback);
1449
- Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(), { env.Null(), data, info });
1450
- }
1451
- } else {
1452
- // Add file size to info
1453
- if (baton->formatOut != "dz" || sharp::IsDzZip(baton->fileOut)) {
1454
- try {
1455
- uint32_t const size = static_cast<uint32_t>(
1456
- std::filesystem::file_size(std::filesystem::u8path(baton->fileOut)));
1457
- info.Set("size", size);
1458
- } catch (...) {}
1459
- }
1460
- Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(), { env.Null(), info });
1461
- }
1462
- } else {
1463
- Callback().SHARP_CALLBACK_FN_NAME(Receiver().Value(),
1464
- { Napi::Error::New(env, sharp::TrimEnd(baton->err)).Value() });
1465
- }
1466
-
1467
- // Delete baton
1468
- delete baton->input;
1469
- delete baton->boolean;
1470
- for (Composite *composite : baton->composite) {
1471
- delete composite->input;
1472
- delete composite;
1473
- }
1474
- for (sharp::InputDescriptor *input : baton->joinChannelIn) {
1475
- delete input;
1476
- }
1477
- for (sharp::InputDescriptor *input : baton->join) {
1478
- delete input;
1479
- }
1480
- delete baton;
1481
-
1482
- // Decrement processing task counter
1483
- sharp::counterProcess--;
1484
- Napi::Number queueLength = Napi::Number::New(env, static_cast<int>(sharp::counterQueue));
1485
- queueListener.SHARP_CALLBACK_FN_NAME(Receiver().Value(), { queueLength });
1486
- }
1487
-
1488
- private:
1489
- PipelineBaton *baton;
1490
- Napi::FunctionReference debuglog;
1491
- Napi::FunctionReference queueListener;
1492
-
1493
- void MultiPageUnsupported(int const pages, std::string op) {
1494
- if (pages > 1) {
1495
- throw std::runtime_error(op + " is not supported for multi-page images");
1496
- }
1497
- }
1498
-
1499
- void KeepGainMapUnsupported(bool const keepGainMap, std::string op) {
1500
- if (keepGainMap) {
1501
- throw std::runtime_error(op + " is not supported when keeping gain maps");
1502
- }
1503
- }
1504
-
1505
- /*
1506
- Calculate the angle of rotation and need-to-flip for the given Exif orientation
1507
- By default, returns zero, i.e. no rotation.
1508
- */
1509
- std::tuple<VipsAngle, bool>
1510
- CalculateExifRotationAndFlop(int const exifOrientation) {
1511
- VipsAngle rotate = VIPS_ANGLE_D0;
1512
- bool flop = false;
1513
- switch (exifOrientation) {
1514
- case 6: rotate = VIPS_ANGLE_D90; break;
1515
- case 3: rotate = VIPS_ANGLE_D180; break;
1516
- case 8: rotate = VIPS_ANGLE_D270; break;
1517
- case 2: flop = true; break;
1518
- case 7: flop = true; rotate = VIPS_ANGLE_D270; break;
1519
- case 4: flop = true; rotate = VIPS_ANGLE_D180; break;
1520
- case 5: flop = true; rotate = VIPS_ANGLE_D90; break;
1521
- }
1522
- return std::make_tuple(rotate, flop);
1523
- }
1524
-
1525
- /*
1526
- Calculate the rotation for the given angle.
1527
- Supports any positive or negative angle that is a multiple of 90.
1528
- */
1529
- VipsAngle
1530
- CalculateAngleRotation(int angle) {
1531
- angle = angle % 360;
1532
- if (angle < 0)
1533
- angle = 360 + angle;
1534
- switch (angle) {
1535
- case 90: return VIPS_ANGLE_D90;
1536
- case 180: return VIPS_ANGLE_D180;
1537
- case 270: return VIPS_ANGLE_D270;
1538
- }
1539
- return VIPS_ANGLE_D0;
1540
- }
1541
-
1542
- /*
1543
- Assemble the suffix argument to dzsave, which is the format (by extname)
1544
- alongside comma-separated arguments to the corresponding `formatsave` vips
1545
- action.
1546
- */
1547
- std::string
1548
- AssembleSuffixString(std::string extname, std::vector<std::pair<std::string, std::string>> options) {
1549
- std::string argument;
1550
- for (const auto& [key, value] : options) {
1551
- if (!argument.empty()) {
1552
- argument += ",";
1553
- }
1554
- argument += key + "=" + value;
1555
- }
1556
- return extname + "[" + argument + "]";
1557
- }
1558
-
1559
- /*
1560
- Build VOption for dzsave
1561
- */
1562
- vips::VOption*
1563
- BuildOptionsDZ(PipelineBaton *baton) {
1564
- // Forward format options through suffix
1565
- std::string suffix;
1566
- if (baton->tileFormat == "png") {
1567
- std::vector<std::pair<std::string, std::string>> options {
1568
- {"interlace", baton->pngProgressive ? "true" : "false"},
1569
- {"compression", std::to_string(baton->pngCompressionLevel)},
1570
- {"filter", baton->pngAdaptiveFiltering ? "all" : "none"}
1571
- };
1572
- suffix = AssembleSuffixString(".png", options);
1573
- } else if (baton->tileFormat == "webp") {
1574
- std::vector<std::pair<std::string, std::string>> options {
1575
- {"Q", std::to_string(baton->webpQuality)},
1576
- {"alpha_q", std::to_string(baton->webpAlphaQuality)},
1577
- {"lossless", baton->webpLossless ? "true" : "false"},
1578
- {"near_lossless", baton->webpNearLossless ? "true" : "false"},
1579
- {"smart_subsample", baton->webpSmartSubsample ? "true" : "false"},
1580
- {"smart_deblock", baton->webpSmartDeblock ? "true" : "false"},
1581
- {"preset", vips_enum_nick(VIPS_TYPE_FOREIGN_WEBP_PRESET, baton->webpPreset)},
1582
- {"min_size", baton->webpMinSize ? "true" : "false"},
1583
- {"mixed", baton->webpMixed ? "true" : "false"},
1584
- {"exact", baton->webpExact ? "true" : "false"},
1585
- {"effort", std::to_string(baton->webpEffort)}
1586
- };
1587
- suffix = AssembleSuffixString(".webp", options);
1588
- } else {
1589
- std::vector<std::pair<std::string, std::string>> options {
1590
- {"Q", std::to_string(baton->jpegQuality)},
1591
- {"interlace", baton->jpegProgressive ? "true" : "false"},
1592
- {"subsample_mode", baton->jpegChromaSubsampling == "4:4:4" ? "off" : "on"},
1593
- {"trellis_quant", baton->jpegTrellisQuantisation ? "true" : "false"},
1594
- {"quant_table", std::to_string(baton->jpegQuantisationTable)},
1595
- {"overshoot_deringing", baton->jpegOvershootDeringing ? "true": "false"},
1596
- {"optimize_scans", baton->jpegOptimiseScans ? "true": "false"},
1597
- {"optimize_coding", baton->jpegOptimiseCoding ? "true": "false"}
1598
- };
1599
- std::string extname = baton->tileLayout == VIPS_FOREIGN_DZ_LAYOUT_DZ ? ".jpeg" : ".jpg";
1600
- suffix = AssembleSuffixString(extname, options);
1601
- }
1602
- vips::VOption *options = VImage::option()
1603
- ->set("keep", baton->keepMetadata)
1604
- ->set("tile_size", baton->tileSize)
1605
- ->set("overlap", baton->tileOverlap)
1606
- ->set("container", baton->tileContainer)
1607
- ->set("layout", baton->tileLayout)
1608
- ->set("suffix", const_cast<char*>(suffix.data()))
1609
- ->set("angle", CalculateAngleRotation(baton->tileAngle))
1610
- ->set("background", baton->tileBackground)
1611
- ->set("centre", baton->tileCentre)
1612
- ->set("id", const_cast<char*>(baton->tileId.data()))
1613
- ->set("skip_blanks", baton->tileSkipBlanks);
1614
- if (baton->tileDepth < VIPS_FOREIGN_DZ_DEPTH_LAST) {
1615
- options->set("depth", baton->tileDepth);
1616
- }
1617
- if (!baton->tileBasename.empty()) {
1618
- options->set("basename", const_cast<char*>(baton->tileBasename.data()));
1619
- }
1620
- return options;
1621
- }
1622
-
1623
- VImage ReattachGainMap(VImage image, VImage gainMap, PipelineBaton *baton) {
1624
- VipsArea *gainMapJpeg = reinterpret_cast<VipsArea*>(gainMap.jpegsave_buffer(VImage::option()
1625
- ->set("keep", FALSE)
1626
- ->set("Q", baton->jpegQuality)
1627
- ->set("subsample_mode", VIPS_FOREIGN_SUBSAMPLE_OFF)
1628
- ->set("trellis_quant", baton->jpegTrellisQuantisation)
1629
- ->set("quant_table", baton->jpegQuantisationTable)
1630
- ->set("overshoot_deringing", baton->jpegOvershootDeringing)
1631
- ->set("optimize_coding", baton->jpegOptimiseCoding)));
1632
- image = image.copy();
1633
- image.set("gainmap-data", reinterpret_cast<VipsCallbackFn>(vips_area_free_cb),
1634
- gainMapJpeg->data, gainMapJpeg->length);
1635
- return image;
1636
- }
1637
-
1638
- /*
1639
- Clear all thread-local data.
1640
- */
1641
- void Error() {
1642
- // Clean up libvips' per-request data and threads
1643
- vips_error_clear();
1644
- vips_thread_shutdown();
1645
- }
1646
- };
1647
-
1648
- /*
1649
- pipeline(options, output, callback)
1650
- */
1651
- Napi::Value pipeline(const Napi::CallbackInfo& info) {
1652
- // V8 objects are converted to non-V8 types held in the baton struct
1653
- PipelineBaton *baton = new PipelineBaton;
1654
- Napi::Object options = info[size_t(0)].As<Napi::Object>();
1655
-
1656
- // Input
1657
- baton->input = sharp::CreateInputDescriptor(options.Get("input").As<Napi::Object>());
1658
- // Join images together
1659
- if (sharp::HasAttr(options, "join")) {
1660
- Napi::Array join = options.Get("join").As<Napi::Array>();
1661
- for (unsigned int i = 0; i < join.Length(); i++) {
1662
- baton->join.push_back(
1663
- sharp::CreateInputDescriptor(join.Get(i).As<Napi::Object>()));
1664
- }
1665
- }
1666
- // Extract image options
1667
- baton->topOffsetPre = sharp::AttrAsInt32(options, "topOffsetPre");
1668
- baton->leftOffsetPre = sharp::AttrAsInt32(options, "leftOffsetPre");
1669
- baton->widthPre = sharp::AttrAsInt32(options, "widthPre");
1670
- baton->heightPre = sharp::AttrAsInt32(options, "heightPre");
1671
- baton->topOffsetPost = sharp::AttrAsInt32(options, "topOffsetPost");
1672
- baton->leftOffsetPost = sharp::AttrAsInt32(options, "leftOffsetPost");
1673
- baton->widthPost = sharp::AttrAsInt32(options, "widthPost");
1674
- baton->heightPost = sharp::AttrAsInt32(options, "heightPost");
1675
- // Output image dimensions
1676
- baton->width = sharp::AttrAsInt32(options, "width");
1677
- baton->height = sharp::AttrAsInt32(options, "height");
1678
- // Canvas option
1679
- std::string canvas = sharp::AttrAsStr(options, "canvas");
1680
- if (canvas == "crop") {
1681
- baton->canvas = sharp::Canvas::CROP;
1682
- } else if (canvas == "embed") {
1683
- baton->canvas = sharp::Canvas::EMBED;
1684
- } else if (canvas == "max") {
1685
- baton->canvas = sharp::Canvas::MAX;
1686
- } else if (canvas == "min") {
1687
- baton->canvas = sharp::Canvas::MIN;
1688
- } else if (canvas == "ignore_aspect") {
1689
- baton->canvas = sharp::Canvas::IGNORE_ASPECT;
1690
- }
1691
- // Composite
1692
- Napi::Array compositeArray = options.Get("composite").As<Napi::Array>();
1693
- for (unsigned int i = 0; i < compositeArray.Length(); i++) {
1694
- Napi::Object compositeObject = compositeArray.Get(i).As<Napi::Object>();
1695
- Composite *composite = new Composite;
1696
- composite->input = sharp::CreateInputDescriptor(compositeObject.Get("input").As<Napi::Object>());
1697
- composite->mode = sharp::AttrAsEnum<VipsBlendMode>(compositeObject, "blend", VIPS_TYPE_BLEND_MODE);
1698
- composite->gravity = sharp::AttrAsUint32(compositeObject, "gravity");
1699
- composite->left = sharp::AttrAsInt32(compositeObject, "left");
1700
- composite->top = sharp::AttrAsInt32(compositeObject, "top");
1701
- composite->hasOffset = sharp::AttrAsBool(compositeObject, "hasOffset");
1702
- composite->tile = sharp::AttrAsBool(compositeObject, "tile");
1703
- composite->premultiplied = sharp::AttrAsBool(compositeObject, "premultiplied");
1704
- baton->composite.push_back(composite);
1705
- }
1706
- // Resize options
1707
- baton->withoutEnlargement = sharp::AttrAsBool(options, "withoutEnlargement");
1708
- baton->withoutReduction = sharp::AttrAsBool(options, "withoutReduction");
1709
- baton->position = sharp::AttrAsInt32(options, "position");
1710
- baton->resizeBackground = sharp::AttrAsVectorOfDouble(options, "resizeBackground");
1711
- baton->kernel = sharp::AttrAsEnum<VipsKernel>(options, "kernel", VIPS_TYPE_KERNEL);
1712
- baton->fastShrinkOnLoad = sharp::AttrAsBool(options, "fastShrinkOnLoad");
1713
- // Join Channel Options
1714
- if (options.Has("joinChannelIn")) {
1715
- Napi::Array joinChannelArray = options.Get("joinChannelIn").As<Napi::Array>();
1716
- for (unsigned int i = 0; i < joinChannelArray.Length(); i++) {
1717
- baton->joinChannelIn.push_back(
1718
- sharp::CreateInputDescriptor(joinChannelArray.Get(i).As<Napi::Object>()));
1719
- }
1720
- }
1721
- // Operators
1722
- baton->flatten = sharp::AttrAsBool(options, "flatten");
1723
- baton->flattenBackground = sharp::AttrAsVectorOfDouble(options, "flattenBackground");
1724
- baton->unflatten = sharp::AttrAsBool(options, "unflatten");
1725
- baton->negate = sharp::AttrAsBool(options, "negate");
1726
- baton->negateAlpha = sharp::AttrAsBool(options, "negateAlpha");
1727
- baton->blurSigma = sharp::AttrAsDouble(options, "blurSigma");
1728
- baton->precision = sharp::AttrAsEnum<VipsPrecision>(options, "precision", VIPS_TYPE_PRECISION);
1729
- baton->minAmpl = sharp::AttrAsDouble(options, "minAmpl");
1730
- baton->brightness = sharp::AttrAsDouble(options, "brightness");
1731
- baton->saturation = sharp::AttrAsDouble(options, "saturation");
1732
- baton->hue = sharp::AttrAsInt32(options, "hue");
1733
- baton->lightness = sharp::AttrAsDouble(options, "lightness");
1734
- baton->medianSize = sharp::AttrAsUint32(options, "medianSize");
1735
- baton->sharpenSigma = sharp::AttrAsDouble(options, "sharpenSigma");
1736
- baton->sharpenM1 = sharp::AttrAsDouble(options, "sharpenM1");
1737
- baton->sharpenM2 = sharp::AttrAsDouble(options, "sharpenM2");
1738
- baton->sharpenX1 = sharp::AttrAsDouble(options, "sharpenX1");
1739
- baton->sharpenY2 = sharp::AttrAsDouble(options, "sharpenY2");
1740
- baton->sharpenY3 = sharp::AttrAsDouble(options, "sharpenY3");
1741
- baton->threshold = sharp::AttrAsInt32(options, "threshold");
1742
- baton->thresholdGrayscale = sharp::AttrAsBool(options, "thresholdGrayscale");
1743
- baton->trimBackground = sharp::AttrAsVectorOfDouble(options, "trimBackground");
1744
- baton->trimThreshold = sharp::AttrAsDouble(options, "trimThreshold");
1745
- baton->trimLineArt = sharp::AttrAsBool(options, "trimLineArt");
1746
- baton->trimMargin = sharp::AttrAsUint32(options, "trimMargin");
1747
- baton->gamma = sharp::AttrAsDouble(options, "gamma");
1748
- baton->gammaOut = sharp::AttrAsDouble(options, "gammaOut");
1749
- baton->linearA = sharp::AttrAsVectorOfDouble(options, "linearA");
1750
- baton->linearB = sharp::AttrAsVectorOfDouble(options, "linearB");
1751
- baton->dilateWidth = sharp::AttrAsUint32(options, "dilateWidth");
1752
- baton->erodeWidth = sharp::AttrAsUint32(options, "erodeWidth");
1753
- baton->greyscale = sharp::AttrAsBool(options, "greyscale");
1754
- baton->normalise = sharp::AttrAsBool(options, "normalise");
1755
- baton->normaliseLower = sharp::AttrAsUint32(options, "normaliseLower");
1756
- baton->normaliseUpper = sharp::AttrAsUint32(options, "normaliseUpper");
1757
- baton->tint = sharp::AttrAsVectorOfDouble(options, "tint");
1758
- baton->claheWidth = sharp::AttrAsUint32(options, "claheWidth");
1759
- baton->claheHeight = sharp::AttrAsUint32(options, "claheHeight");
1760
- baton->claheMaxSlope = sharp::AttrAsUint32(options, "claheMaxSlope");
1761
- baton->angle = sharp::AttrAsInt32(options, "angle");
1762
- baton->rotationAngle = sharp::AttrAsDouble(options, "rotationAngle");
1763
- baton->rotationBackground = sharp::AttrAsVectorOfDouble(options, "rotationBackground");
1764
- baton->rotateBefore = sharp::AttrAsBool(options, "rotateBefore");
1765
- baton->orientBefore = sharp::AttrAsBool(options, "orientBefore");
1766
- baton->flip = sharp::AttrAsBool(options, "flip");
1767
- baton->flop = sharp::AttrAsBool(options, "flop");
1768
- baton->extendTop = sharp::AttrAsInt32(options, "extendTop");
1769
- baton->extendBottom = sharp::AttrAsInt32(options, "extendBottom");
1770
- baton->extendLeft = sharp::AttrAsInt32(options, "extendLeft");
1771
- baton->extendRight = sharp::AttrAsInt32(options, "extendRight");
1772
- baton->extendBackground = sharp::AttrAsVectorOfDouble(options, "extendBackground");
1773
- baton->extendWith = sharp::AttrAsEnum<VipsExtend>(options, "extendWith", VIPS_TYPE_EXTEND);
1774
- baton->extractChannel = sharp::AttrAsInt32(options, "extractChannel");
1775
- baton->affineMatrix = sharp::AttrAsVectorOfDouble(options, "affineMatrix");
1776
- baton->affineBackground = sharp::AttrAsVectorOfDouble(options, "affineBackground");
1777
- baton->affineIdx = sharp::AttrAsDouble(options, "affineIdx");
1778
- baton->affineIdy = sharp::AttrAsDouble(options, "affineIdy");
1779
- baton->affineOdx = sharp::AttrAsDouble(options, "affineOdx");
1780
- baton->affineOdy = sharp::AttrAsDouble(options, "affineOdy");
1781
- baton->affineInterpolator = sharp::AttrAsStr(options, "affineInterpolator");
1782
- baton->removeAlpha = sharp::AttrAsBool(options, "removeAlpha");
1783
- baton->ensureAlpha = sharp::AttrAsDouble(options, "ensureAlpha");
1784
- if (options.Has("boolean")) {
1785
- baton->boolean = sharp::CreateInputDescriptor(options.Get("boolean").As<Napi::Object>());
1786
- baton->booleanOp = sharp::AttrAsEnum<VipsOperationBoolean>(options, "booleanOp", VIPS_TYPE_OPERATION_BOOLEAN);
1787
- }
1788
- if (options.Has("bandBoolOp")) {
1789
- baton->bandBoolOp = sharp::AttrAsEnum<VipsOperationBoolean>(options, "bandBoolOp", VIPS_TYPE_OPERATION_BOOLEAN);
1790
- }
1791
- if (options.Has("convKernel")) {
1792
- Napi::Object kernel = options.Get("convKernel").As<Napi::Object>();
1793
- baton->convKernelWidth = sharp::AttrAsUint32(kernel, "width");
1794
- baton->convKernelHeight = sharp::AttrAsUint32(kernel, "height");
1795
- baton->convKernelScale = sharp::AttrAsDouble(kernel, "scale");
1796
- baton->convKernelOffset = sharp::AttrAsDouble(kernel, "offset");
1797
- size_t const kernelSize = static_cast<size_t>(baton->convKernelWidth * baton->convKernelHeight);
1798
- baton->convKernel.resize(kernelSize);
1799
- Napi::Array kdata = kernel.Get("kernel").As<Napi::Array>();
1800
- for (unsigned int i = 0; i < kernelSize; i++) {
1801
- baton->convKernel[i] = sharp::AttrAsDouble(kdata, i);
1802
- }
1803
- }
1804
- if (options.Has("recombMatrix")) {
1805
- Napi::Array recombMatrix = options.Get("recombMatrix").As<Napi::Array>();
1806
- unsigned int matrixElements = recombMatrix.Length();
1807
- baton->recombMatrix.resize(matrixElements);
1808
- for (unsigned int i = 0; i < matrixElements; i++) {
1809
- baton->recombMatrix[i] = sharp::AttrAsDouble(recombMatrix, i);
1810
- }
1811
- }
1812
- baton->colourspacePipeline = sharp::AttrAsEnum<VipsInterpretation>(
1813
- options, "colourspacePipeline", VIPS_TYPE_INTERPRETATION);
1814
- if (baton->colourspacePipeline == VIPS_INTERPRETATION_ERROR) {
1815
- baton->colourspacePipeline = VIPS_INTERPRETATION_LAST;
1816
- }
1817
- baton->colourspace = sharp::AttrAsEnum<VipsInterpretation>(options, "colourspace", VIPS_TYPE_INTERPRETATION);
1818
- if (baton->colourspace == VIPS_INTERPRETATION_ERROR) {
1819
- baton->colourspace = VIPS_INTERPRETATION_sRGB;
1820
- }
1821
- // Output
1822
- baton->formatOut = sharp::AttrAsStr(options, "formatOut");
1823
- baton->fileOut = sharp::AttrAsStr(options, "fileOut");
1824
- baton->typedArrayOut = sharp::AttrAsBool(options, "typedArrayOut");
1825
- baton->keepMetadata = sharp::AttrAsUint32(options, "keepMetadata");
1826
- baton->withMetadataOrientation = sharp::AttrAsUint32(options, "withMetadataOrientation");
1827
- baton->withMetadataDensity = sharp::AttrAsDouble(options, "withMetadataDensity");
1828
- baton->withIccProfile = sharp::AttrAsStr(options, "withIccProfile");
1829
- Napi::Object withExif = options.Get("withExif").As<Napi::Object>();
1830
- Napi::Array withExifKeys = withExif.GetPropertyNames();
1831
- for (unsigned int i = 0; i < withExifKeys.Length(); i++) {
1832
- std::string k = sharp::AttrAsStr(withExifKeys, i);
1833
- if (withExif.HasOwnProperty(k)) {
1834
- baton->withExif.insert(std::make_pair(k, sharp::AttrAsStr(withExif, k)));
1835
- }
1836
- }
1837
- baton->withExifMerge = sharp::AttrAsBool(options, "withExifMerge");
1838
- baton->withXmp = sharp::AttrAsStr(options, "withXmp");
1839
- baton->keepGainMap = sharp::AttrAsBool(options, "keepGainMap");
1840
- baton->withGainMap = sharp::AttrAsBool(options, "withGainMap");
1841
- baton->timeoutSeconds = sharp::AttrAsUint32(options, "timeoutSeconds");
1842
- baton->loop = sharp::AttrAsUint32(options, "loop");
1843
- baton->delay = sharp::AttrAsInt32Vector(options, "delay");
1844
- // Format-specific
1845
- baton->jpegQuality = sharp::AttrAsUint32(options, "jpegQuality");
1846
- baton->jpegProgressive = sharp::AttrAsBool(options, "jpegProgressive");
1847
- baton->jpegChromaSubsampling = sharp::AttrAsStr(options, "jpegChromaSubsampling");
1848
- baton->jpegTrellisQuantisation = sharp::AttrAsBool(options, "jpegTrellisQuantisation");
1849
- baton->jpegQuantisationTable = sharp::AttrAsUint32(options, "jpegQuantisationTable");
1850
- baton->jpegOvershootDeringing = sharp::AttrAsBool(options, "jpegOvershootDeringing");
1851
- baton->jpegOptimiseScans = sharp::AttrAsBool(options, "jpegOptimiseScans");
1852
- baton->jpegOptimiseCoding = sharp::AttrAsBool(options, "jpegOptimiseCoding");
1853
- baton->pngProgressive = sharp::AttrAsBool(options, "pngProgressive");
1854
- baton->pngCompressionLevel = sharp::AttrAsUint32(options, "pngCompressionLevel");
1855
- baton->pngAdaptiveFiltering = sharp::AttrAsBool(options, "pngAdaptiveFiltering");
1856
- baton->pngPalette = sharp::AttrAsBool(options, "pngPalette");
1857
- baton->pngQuality = sharp::AttrAsUint32(options, "pngQuality");
1858
- baton->pngEffort = sharp::AttrAsUint32(options, "pngEffort");
1859
- baton->pngBitdepth = sharp::AttrAsUint32(options, "pngBitdepth");
1860
- baton->pngDither = sharp::AttrAsDouble(options, "pngDither");
1861
- baton->jp2Quality = sharp::AttrAsUint32(options, "jp2Quality");
1862
- baton->jp2Lossless = sharp::AttrAsBool(options, "jp2Lossless");
1863
- baton->jp2TileHeight = sharp::AttrAsUint32(options, "jp2TileHeight");
1864
- baton->jp2TileWidth = sharp::AttrAsUint32(options, "jp2TileWidth");
1865
- baton->jp2ChromaSubsampling = sharp::AttrAsStr(options, "jp2ChromaSubsampling");
1866
- baton->webpQuality = sharp::AttrAsUint32(options, "webpQuality");
1867
- baton->webpAlphaQuality = sharp::AttrAsUint32(options, "webpAlphaQuality");
1868
- baton->webpLossless = sharp::AttrAsBool(options, "webpLossless");
1869
- baton->webpNearLossless = sharp::AttrAsBool(options, "webpNearLossless");
1870
- baton->webpSmartSubsample = sharp::AttrAsBool(options, "webpSmartSubsample");
1871
- baton->webpSmartDeblock = sharp::AttrAsBool(options, "webpSmartDeblock");
1872
- baton->webpPreset = sharp::AttrAsEnum<VipsForeignWebpPreset>(options, "webpPreset", VIPS_TYPE_FOREIGN_WEBP_PRESET);
1873
- baton->webpEffort = sharp::AttrAsUint32(options, "webpEffort");
1874
- baton->webpMinSize = sharp::AttrAsBool(options, "webpMinSize");
1875
- baton->webpMixed = sharp::AttrAsBool(options, "webpMixed");
1876
- baton->webpExact = sharp::AttrAsBool(options, "webpExact");
1877
- baton->gifBitdepth = sharp::AttrAsUint32(options, "gifBitdepth");
1878
- baton->gifEffort = sharp::AttrAsUint32(options, "gifEffort");
1879
- baton->gifDither = sharp::AttrAsDouble(options, "gifDither");
1880
- baton->gifInterFrameMaxError = sharp::AttrAsDouble(options, "gifInterFrameMaxError");
1881
- baton->gifInterPaletteMaxError = sharp::AttrAsDouble(options, "gifInterPaletteMaxError");
1882
- baton->gifKeepDuplicateFrames = sharp::AttrAsBool(options, "gifKeepDuplicateFrames");
1883
- baton->gifReuse = sharp::AttrAsBool(options, "gifReuse");
1884
- baton->gifProgressive = sharp::AttrAsBool(options, "gifProgressive");
1885
- baton->tiffQuality = sharp::AttrAsUint32(options, "tiffQuality");
1886
- baton->tiffBigtiff = sharp::AttrAsBool(options, "tiffBigtiff");
1887
- baton->tiffPyramid = sharp::AttrAsBool(options, "tiffPyramid");
1888
- baton->tiffMiniswhite = sharp::AttrAsBool(options, "tiffMiniswhite");
1889
- baton->tiffBitdepth = sharp::AttrAsUint32(options, "tiffBitdepth");
1890
- baton->tiffTile = sharp::AttrAsBool(options, "tiffTile");
1891
- baton->tiffTileWidth = sharp::AttrAsUint32(options, "tiffTileWidth");
1892
- baton->tiffTileHeight = sharp::AttrAsUint32(options, "tiffTileHeight");
1893
- baton->tiffXres = sharp::AttrAsDouble(options, "tiffXres");
1894
- baton->tiffYres = sharp::AttrAsDouble(options, "tiffYres");
1895
- if (baton->tiffXres == 1.0 && baton->tiffYres == 1.0 && baton->withMetadataDensity > 0) {
1896
- baton->tiffXres = baton->tiffYres = baton->withMetadataDensity / 25.4;
1897
- }
1898
- baton->tiffCompression = sharp::AttrAsEnum<VipsForeignTiffCompression>(
1899
- options, "tiffCompression", VIPS_TYPE_FOREIGN_TIFF_COMPRESSION);
1900
- baton->tiffPredictor = sharp::AttrAsEnum<VipsForeignTiffPredictor>(
1901
- options, "tiffPredictor", VIPS_TYPE_FOREIGN_TIFF_PREDICTOR);
1902
- baton->tiffResolutionUnit = sharp::AttrAsEnum<VipsForeignTiffResunit>(
1903
- options, "tiffResolutionUnit", VIPS_TYPE_FOREIGN_TIFF_RESUNIT);
1904
- baton->heifQuality = sharp::AttrAsUint32(options, "heifQuality");
1905
- baton->heifLossless = sharp::AttrAsBool(options, "heifLossless");
1906
- baton->heifCompression = sharp::AttrAsEnum<VipsForeignHeifCompression>(
1907
- options, "heifCompression", VIPS_TYPE_FOREIGN_HEIF_COMPRESSION);
1908
- baton->heifEffort = sharp::AttrAsUint32(options, "heifEffort");
1909
- baton->heifChromaSubsampling = sharp::AttrAsStr(options, "heifChromaSubsampling");
1910
- baton->heifBitdepth = sharp::AttrAsUint32(options, "heifBitdepth");
1911
- baton->heifTune = sharp::AttrAsStr(options, "heifTune");
1912
- baton->jxlDistance = sharp::AttrAsDouble(options, "jxlDistance");
1913
- baton->jxlDecodingTier = sharp::AttrAsUint32(options, "jxlDecodingTier");
1914
- baton->jxlEffort = sharp::AttrAsUint32(options, "jxlEffort");
1915
- baton->jxlLossless = sharp::AttrAsBool(options, "jxlLossless");
1916
- baton->rawDepth = sharp::AttrAsEnum<VipsBandFormat>(options, "rawDepth", VIPS_TYPE_BAND_FORMAT);
1917
- baton->tileSize = sharp::AttrAsUint32(options, "tileSize");
1918
- baton->tileOverlap = sharp::AttrAsUint32(options, "tileOverlap");
1919
- baton->tileAngle = sharp::AttrAsInt32(options, "tileAngle");
1920
- baton->tileBackground = sharp::AttrAsVectorOfDouble(options, "tileBackground");
1921
- baton->tileSkipBlanks = sharp::AttrAsInt32(options, "tileSkipBlanks");
1922
- baton->tileContainer = sharp::AttrAsEnum<VipsForeignDzContainer>(
1923
- options, "tileContainer", VIPS_TYPE_FOREIGN_DZ_CONTAINER);
1924
- baton->tileLayout = sharp::AttrAsEnum<VipsForeignDzLayout>(options, "tileLayout", VIPS_TYPE_FOREIGN_DZ_LAYOUT);
1925
- baton->tileFormat = sharp::AttrAsStr(options, "tileFormat");
1926
- baton->tileDepth = sharp::AttrAsEnum<VipsForeignDzDepth>(options, "tileDepth", VIPS_TYPE_FOREIGN_DZ_DEPTH);
1927
- baton->tileCentre = sharp::AttrAsBool(options, "tileCentre");
1928
- baton->tileId = sharp::AttrAsStr(options, "tileId");
1929
- baton->tileBasename = sharp::AttrAsStr(options, "tileBasename");
1930
-
1931
- // Function to notify of libvips warnings
1932
- Napi::Function debuglog = options.Get("debuglog").As<Napi::Function>();
1933
-
1934
- // Function to notify of queue length changes
1935
- Napi::Function queueListener = options.Get("queueListener").As<Napi::Function>();
1936
-
1937
- // Join queue for worker thread
1938
- Napi::Function callback = info[size_t(1)].As<Napi::Function>();
1939
- PipelineWorker *worker = new PipelineWorker(callback, baton, debuglog, queueListener);
1940
- worker->Receiver().Set("options", options);
1941
- worker->Queue();
1942
-
1943
- // Increment queued task counter
1944
- Napi::Number queueLength = Napi::Number::New(info.Env(), static_cast<int>(++sharp::counterQueue));
1945
- queueListener.SHARP_CALLBACK_FN_NAME(info.This(), { queueLength });
1946
-
1947
- return info.Env().Undefined();
1948
- }