Image Optimization Script #348

Merged
a258wang merged 45 commits from amy-image-optimization into main 2021-10-31 16:58:16 -04:00
Owner

A build-time script to optimize images. Note that going forward, all images should be placed in images instead of public/images.

Staging: https://csclub.uwaterloo.ca/~a3thakra/csc/amy-image-optimization/

Future improvements:

  • Watch the images folder for updates, and automatically rebuild/refresh the page during development
  • Only re-optimize changed images when running the script?
  • Serve different sizes of images depending on user's screen size
A build-time script to optimize images. Note that going forward, all images should be placed in `images` instead of `public/images`. Staging: https://csclub.uwaterloo.ca/~a3thakra/csc/amy-image-optimization/ Future improvements: - Watch the images folder for updates, and automatically rebuild/refresh the page during development - Only re-optimize changed images when running the script? - Serve different sizes of images depending on user's screen size
a258wang added 7 commits 2021-10-15 00:47:25 -04:00
a258wang added 1 commit 2021-10-15 00:54:00 -04:00
continuous-integration/drone/push Build is passing Details
3519e87e42
Change dependencies
a258wang added 1 commit 2021-10-15 01:04:08 -04:00
continuous-integration/drone/push Build is passing Details
8cd3a7747b
Remove unecessary dependency
a258wang changed title from Image Optimization Script to WIP: Image Optimization Script 2021-10-15 01:10:00 -04:00
a258wang added 1 commit 2021-10-15 23:39:45 -04:00
continuous-integration/drone/push Build is failing Details
aa32e20c6e
Rename npm scripts
a258wang added 1 commit 2021-10-16 01:15:19 -04:00
continuous-integration/drone/push Build is failing Details
92eec34fa7
Remove imagePool constructor parameter
a258wang added 1 commit 2021-10-16 19:46:37 -04:00
continuous-integration/drone/push Build is passing Details
f5adb69bdd
Remove all libsquoosh code
a258wang added 1 commit 2021-10-16 19:53:07 -04:00
a258wang force-pushed amy-image-optimization from fddae28822 to 609d10732c 2021-10-16 20:05:15 -04:00 Compare
a258wang added 2 commits 2021-10-16 20:12:45 -04:00
a258wang added 1 commit 2021-10-16 20:14:38 -04:00
continuous-integration/drone/push Build encountered an error Details
ecfbb721a5
Change order of build steps
a258wang added 1 commit 2021-10-16 20:15:34 -04:00
continuous-integration/drone/push Build is passing Details
a7bf6f56a3
Fix CI step dependencies
a258wang added 2 commits 2021-10-16 20:39:29 -04:00
continuous-integration/drone/push Build encountered an error Details
fbbfaf9fff
Change pipeline steps order
a258wang added 1 commit 2021-10-16 20:40:52 -04:00
continuous-integration/drone/push Build is failing Details
72cd1ee06c
Change pipeline steps order for real
a258wang added 1 commit 2021-10-16 20:46:36 -04:00
continuous-integration/drone/push Build is failing Details
388bf799ab
Change pipeline steps order again
a258wang added 2 commits 2021-10-16 20:53:16 -04:00
a258wang added 1 commit 2021-10-16 21:29:17 -04:00
continuous-integration/drone/push Build is passing Details
7408cf421a
Add descriptive comment
a258wang added 1 commit 2021-10-16 22:37:56 -04:00
continuous-integration/drone/push Build is passing Details
5b6a3e98ab
Change build order
a258wang added 2 commits 2021-10-16 23:04:14 -04:00
a258wang added 1 commit 2021-10-16 23:30:12 -04:00
continuous-integration/drone/push Build is passing Details
06123e8adb
Merge branch 'main' into amy-image-optimization
a258wang force-pushed amy-image-optimization from 680d0a3d02 to b6cd0d3f35 2021-10-17 00:05:53 -04:00 Compare
a258wang changed title from WIP: Image Optimization Script to Image Optimization Script 2021-10-17 00:06:49 -04:00
Author
Owner

I will revert that last commit before merging, after the PR has been approved.

I will revert that last commit before merging, after the PR has been approved.
a258wang added 4 commits 2021-10-24 01:26:22 -04:00
a258wang added 1 commit 2021-10-24 01:27:37 -04:00
continuous-integration/drone/push Build is passing Details
411af4788d
Merge branch 'main' into amy-image-optimization
a258wang changed title from Image Optimization Script to WIP: Image Optimization Script 2021-10-24 01:49:23 -04:00
a258wang added 1 commit 2021-10-24 02:10:10 -04:00
continuous-integration/drone/push Build is failing Details
2ba4b58bfd
Add debugging statement
a258wang added 1 commit 2021-10-24 02:13:10 -04:00
continuous-integration/drone/push Build is passing Details
daa019abf9
Limit numberOfWorkers to maximum 8
a258wang added 2 commits 2021-10-24 02:26:28 -04:00
a258wang added 1 commit 2021-10-24 02:34:26 -04:00
continuous-integration/drone/push Build is passing Details
4f54c51f06
Change numberOfWorkers to maximum 8 for real
a258wang added 1 commit 2021-10-24 02:46:42 -04:00
continuous-integration/drone/push Build is passing Details
fc67cf138a
Remove debugging statements
a258wang added 1 commit 2021-10-24 02:59:53 -04:00
continuous-integration/drone/push Build was killed Details
658b2dafa9
Make PR reviewing easier again
This reverts commit d977f3d65d.
a258wang changed title from WIP: Image Optimization Script to Image Optimization Script 2021-10-24 03:00:28 -04:00
Author
Owner

The pipeline issues and memory errors should be hopefully be fixed now. I will revert that last commit before merging, after the PR has been reviewed and approved.

The pipeline issues and memory errors should be hopefully be fixed now. I will revert that last commit before merging, after the PR has been reviewed and approved.
a3thakra reviewed 2021-10-28 17:18:47 -04:00
@ -0,0 +16,4 @@
const SOURCE_DIRECTORY = "images";
const DESTINATION_DIRECTORY = path.join("public", "images");
const TEAM_IMAGES_DIRECTORY = path.join("team", "");
Owner

isn't this supposed to be path.join("images", "team")

isn't this supposed to be `path.join("images", "team")`
Author
Owner

getFilePathsInDirectory returns the paths of the files relative to the given directory, so the Meet the Team images would have filepaths like team/AdityaThakral.jpg. So the startsWith check on line 62 is checking to see if the filepath starts with team/.

`getFilePathsInDirectory` returns the paths of the files relative to the given directory, so the Meet the Team images would have filepaths like `team/AdityaThakral.jpg`. So the startsWith check on line 62 is checking to see if the filepath starts with `team/`.
Owner

can you add that as a comment in code?

can you add that as a comment in code?
a3thakra approved these changes 2021-10-30 16:07:01 -04:00
a3thakra left a comment
Owner

lgtm after you add that comment

lgtm after you add that comment
a3thakra reviewed 2021-10-30 16:09:29 -04:00
package.json Outdated
@ -8,3 +8,2 @@
"scripts": {
"dev": "next dev",
"build": "npm run build:web && npm run generate:calendar",
"dev": "npm run build:images && next dev",
Owner

Let's not do this everytime. Instead, if someone adds a new image, they should run this locally to see their image. You should also something about adding and optimizing images to the docs.

Let's not do this everytime. Instead, if someone adds a new image, they should run this locally to see their image. You should also something about adding and optimizing images to the docs.
n3parikh approved these changes 2021-10-30 19:48:41 -04:00
@ -0,0 +37,4 @@
const imagePaths = await getFilePathsInDirectory(SOURCE_DIRECTORY);
await fse.emptyDir(DESTINATION_DIRECTORY);
const numberOfWorkers = Math.min(cpus().length, 8);
Owner

Can you leave a comment about the 8?

Can you leave a comment about the 8?
a258wang added 2 commits 2021-10-31 16:37:42 -04:00
continuous-integration/drone/push Build is passing Details
4a49919e26
Revert "Make PR reviewing easier again"
This reverts commit 658b2dafa9.
a258wang added 1 commit 2021-10-31 16:39:23 -04:00
continuous-integration/drone/push Build is passing Details
0f0c636258
Remove image optimization from npm run dev
a258wang merged commit aae5c9adef into main 2021-10-31 16:58:16 -04:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: www/www-new#348
No description provided.