Comments (2)
I implemented a basic resize with the Python Pillow library using the following code:
MM_TO_PIXEL_RATIO = 3.78
# Resize image to reduce file size
if paper_size == "a4":
max_pixel_height = 267 * MM_TO_PIXEL_RATIO
elif paper_size == "letter":
max_pixel_height = 249 * MM_TO_PIXEL_RATIO
(width, height) = base_image.size
if height > max_pixel_height:
ratio = height / max_pixel_height
width *= ratio
height *= ratio
base_image = base_image.resize((int(width), int(height)), Image.ANTIALIAS)
However it's very computationally intensive. It would slow down resource generation considerably for small copies and the Django server threw the Killed
error at 50 copies.
Amusingly I had implemented the ratio calculation the wrong way around... Silly Jack..
I've noticed a rough ~10% decrease in file size with minimal time delays. It would worth timing the process to see if it's worth the time.
from cs-unplugged.
Closed in dfab2a2
from cs-unplugged.
Related Issues (20)
- Solution provided for programming challenge on normal CSU site is not valid for same challenge on the plugging-it-in site.
- PII walkthrough partially unnavigable on small screens
- Fix grid layout of programming topics on PII homepage
- Update documentation for At Home, Plugging it in and related changes
- HTML can be inserted into a user's Plugging it in challenge templates
- Automatically sync subtitles with Vimeo
- Add subtitle to lesson title on topic page regarding intended order of lessons
- Update binary windows to have 4, 5, 6, or 8 bits on one page
- Compress 'at_home' images
- NET::ERR_CERT_COMMON_NAME_INVALID for classic cite HOT 1
- Link to MOOC on "How do I teach CS Unplugged?" page
- Update MOOC page HOT 1
- Clicking item in sidebar table of contents twice hides target heading
- Speaker notes view doesn't reset to top between slides HOT 1
- Update database objects instead of flushing database on deployment HOT 1
- Increase test coverage of loaders HOT 1
- There are a number of programming challenges that aren't linked to lessons
- Style checker tries to check the style of README.txt.py in the build folder
- [Bug]: CI Failing style check
- Use new Django LTS 4.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cs-unplugged.