conclusio / matlab-epsclean Goto Github PK
View Code? Open in Web Editor NEWClean/Repair .eps PostScript vector files created by Matlab R2016b
License: GNU Lesser General Public License v3.0
Clean/Repair .eps PostScript vector files created by Matlab R2016b
License: GNU Lesser General Public License v3.0
This project is a great service to the community. Thanks! I am attaching an example where epsclean removes most, but not all of the artifacts. The original file is fig1.eps and the cleaned version is fig1c.eps (attached inside a zip-file). I have also attached the pdfs (created by Preview on a mac). I tried the four different combinations of true/false for the optional epsclean arguments and they all showed the same behavior. Thanks for your help. -Matt
Your code works really well at cleaning up a very problematic EPS file I have. Thanks!
I noticed that the if
statement on line 60 is a bug in R2016b. It leads to "Undefined function or variable 'newline'." This is because your newline
variable doesn't get defined in R2016b but still shadows the MATLAB built-in.
I think the most direct solution might be to replace lines 161, 165, and 174 with sprintf
statements. i.e.
currentBlockPrefix = sprintf('%s%s\n', currentBlockPrefix ,line);
This has the benefit of not raisng the <AGROW>
warning, so you can even ditch those mlint decorators.
I'd also suggest you don't use line
as a variable name because that shadows another built-in.
Looks like the script does not respect the InvertHardCopy
option set(gcf,'InvertHardCopy','off')
which allows one to save figures with black backgrounds. All my figures with black backgrounds revert to white backgrounds after running this script.
brilliant script for fixing annoying white lines
but not working when I tried to fix the artifacts between areas (MatlabR2017a)
When I run this in MATLAB R2015b, I get the following error:
epsclean('out.eps')
Undefined function or variable 'newline'.
Error in epsclean (line 169)
currentBlockPrefix = [currentBlockPrefix line newline]; %#ok
The "newline" element appears quite often in the code, and I am unsure of why it doesn't work in my version. It seems like this should be the equivalent of '\n' in the concatenated string, and so sprintf('\n') should produce the correct string char's on linux/windows/mac (since they all convert \n to different chars). I branched a local copy of the repo into a "fix_newline" branch and just submitted a pull request.
I installed Matlab 2017b, and found the script will remove some colored areas. For example,
Code:
contourf(peaks(100));saveas(gcf,'figure.eps','epsc')
epsclean('figure.eps','figure_clean.eps','GroupSoft',true,'combineAreas',true,'removeboxes',true)
Generates the following (I converted from eps to pdf for this preview):
Do you have any idea? Thank you for making this tool, regardless!
By grouping elements according to their properties the z-order might change.
An example would be: A blue area which both covers and is covered by yellow areas. When grouping them according to their color, all blue parts are either in front or back of the yellow areas.
This needs a complete rethinking in the code, since dependencies between 'blocks' need to be introduced...
Nice work, such a useful script! I kept getting the following error with my eps files,
Error using containers.Map/subsasgn
Specified key type does not match the type expected for this
container.
Error in epsclean>getBlockData (line 377)
blockMap(blockId) = s; %#ok<NASGU>
Error in epsclean (line 203)
[cbNewBlock,cbConn] =
getBlockData(blockMap,cbPrefix);
I did a little hunting and found that blockId
was occassionally set to []
, so I added the following check to the functions writeBlocks
and getBlockdata
if isempty(blockId)
blockId='';
end
Everything seems to work now. Tested with MATLAB 2016a and 2017a.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.