Comments (16)
yes, images in SVG works too
Lines 267 to 275 in b5f2efc
from leanify.
Good idea, I'll implement it when I have time.
However, there's a little technical problem.
For now, some of the html file are recognized by Leanify as xml file. Should I write a html parser or just use current xml library? Or, maybe just search for data:image/png;base64
?
from leanify.
Thanks for your reply JayXon.
I would say that detecting data:image/png;base64 and data:image/jpeg;base64 would be enough. No matter if they are serialized inside and HTML or an XML, optimizing the encoded base64 data will still make it compatible with both markups.
from leanify.
Just search for "data:image/xxx;base64," (where xxx is gif, jpeg or png ** it might be with mixded, upper or lowercase) and the image will end with " ) or '
For this optimisation of images please add it's own option when Leanify is called to optimise images but not the entire html/css file (just for compatibility reasons). Thank you!
from leanify.
Searching is the easiest way to implement it. The only concern is that if the file is not html/js/css, but it also has data:image/png;base64
in it, we may corrupt the file.
from leanify.
To be honest I do not think that finding an ocurrence such as data:image/???;base64 would be probable in file types other than HTML, XHTML, or XML.
They can happen in server side scripts outputing HTML such as PHP, ASP.NET or JSP, but this will not corrupt the outputed HTML.
Anyway, agree making it an option so it can be disabled.
from leanify.
Well, for example, html is embedded inside of some binary format which has a field of the length of the html.
If I can't find a way to make sure I don't corrupt the file, then I'll have to make the option disabled by default.
from leanify.
Sounds fair making this option disabled by default. Or maybe it can be enabled if detected file extension is known to be safe such as HTML, XML, or XHTML, and left it disabled for PHP, EXE (where HTML could be a resource), ...
from leanify.
Good day!
I have long had the idea to do this project, where the system automatically searches for the image base64 files in HTML, CSS, XML / SVG and extracts them. The draft also easily integrate them into your files back. I think the right thing to do a separate project on this issue.
I have not found a project that could support such.
from leanify.
For images inside binary files (e.g. EXE files) replacing original image with optimised + space padding (until you reach same size as original image data) is best option but first you need to detect in wich kind of filetype you do the optimisation (htm/html.js.xml or binary).
from leanify.
I think I'll only enable this on file with known extension (html, htm, js, css, etc.).
Binary files won't be supported for this feature, even if I add space padding, it may still corrupt the file if it has checksum.
from leanify.
Thank you!
from leanify.
Please try out the latest nightly build.
from leanify.
It works! Test file (css inside) https://ebooks.adelaide.edu.au/o/orwell/george/o79a/o79a.epub
from leanify.
Cool, feel free to create another issue if there are bugs.
from leanify.
To clarify, did this implement optimizing supported embedded images inside SVGs (.svg images), or just in HTML/XML/&c files that have such in them?
from leanify.
Related Issues (20)
- Add --output option to avoid overwrite source file HOT 1
- wasm support
- Recursive compression of images within epub files HOT 3
- How can I restrict specific files or file types from being optimized? HOT 2
- Please release a new version. HOT 5
- LossLess JPEG optimization? HOT 2
- fatal error: 'stdio.h' file not found HOT 1
- Building from source fails HOT 5
- `Map file error: No such device` using mergerFS HOT 2
- [Bug Report]heap-buffer-overflow in function LeanifyFile():leanify.cpp:140 HOT 3
- Add SECURITY.md HOT 5
- [Bug]out-of-memory in function get_mutable_buffer():/pugixml.cpp:2051
- pixel per inch HOT 2
- make error: lib/LZMA/LzmaEnc.c:2996:19: error: storing the address of local variable ‘outStream’ in ‘p_16->rc.outStream’ [-Werror=dangling-pointer=] HOT 1
- Cflags issue on Apple M1 (ARM) HOT 3
- Out of memory error when compiling HOT 10
- [NOISSUE] Was there previously a GUI version called Leanify++? HOT 1
- Is arm64 / aarch64 architecture supported? HOT 1
- Is there a way that to both keep Photo's EXIF and remove Location? HOT 2
- Need periodic releases so that this excellent tool can be picked up by linux/arch repos. HOT 1
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 leanify.