acrosman / image2pattern Goto Github PK
View Code? Open in Web Editor NEWElectron App to convert an image to a cross-stitch pattern.
License: MIT License
Electron App to convert an image to a cross-stitch pattern.
License: MIT License
Currently during image processing for color images an index is built using parameter reassignment and hasOwnProperty, which are both rejected by the airbnb-base linting.
image2pattern/src/image2pattern.js
Lines 47 to 49 in d91dbbf
The whole function needs to be refactored to remove these issues.
There are two test directories, test and tests. The scripts in tests are simple scripts that exercise parts of the code and don't use a proper framework. They should be converted to use Mocha and/or Chai, moved to the test directory so all the tests can run.
Summary
Please try to summarize your feature in a short sentence.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Summary
Remove extraneous white space from the edge of images for black and white patterns.
Is your feature request related to a problem? Please describe.
For black and white patterns white borders are unneeded and just add to the effort of counting, so when the image is being prepared the processor should trim off any extra white space on the edge of the image.
Describe the solution you'd like
When in monochrome mode during the prepImage process any extra white space around the edge of the image should be removed.
Describe the bug
The gen-test script can trigger errors like those seen here: https://circleci.com/gh/acrosman/image2pattern/12
But they do not result is a non-zero exit code from the script.
To Reproduce
Steps to reproduce the behavior:
npm run gen-test
Expected behavior
Errors in test scripts should trigger non-zero response codes. Fixing this should trigger errors in the current code base.
Summary
After the image has been processed, a pixel-by-pixel approach to pattern editing would be helpful for manual clean up.
Is your feature request related to a problem? Please describe.
The automated nature of the image editing process means that processing artifacts may be present in the final image, or other things that might warrant clean up or adjustments.
Describe the solution you'd like
A simple initial draft of an editor that allows individual pixels to be changed to a color from the existing pallet, a new color, or be set to the background color.
The colors.json file provides a list of all DMC colors. For color patterns each color in the pattern should be mapped to the nearest thread color (using closestThreadColor()
in threadColors.js) and then an index of those colors should be included at the end of the pattern.
Several places read and write files using string concatenation instead of the Path module. The code should be updated project wide to use path.
Need electron build scripts.
Summary
Different people want to use different paper sizes for printing. Add support to generate PDFs in various standard sizes.
Is your feature request related to a problem? Please describe:
Right now the app uses the PDFKit default of US Letter sized paper in portrait. It would be good to be able to specify a paper size and orientation.
Describe the solution you'd like
The interface and image2pattern
both need to support at least a few of the paper sizes defined within PDFKit. The list of pre-defined paper sizes are here: https://github.com/foliojs/pdfkit/blob/master/docs/paper_sizes.coffee.md
For image2pattern if could easily be added to settings and defined when the document is created. For the interface a control will be needed on the form and it will need to be added to the process of passing the information into process of generating the pattern.
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
npm install && npm start
[4900:1022/182225.581:ERROR:CONSOLE(5509)] "SyntaxError: Unexpected token / in J SON at position 0", source: chrome-devtools://devtools/bundled/shell.js (5509)
{ imgMaxWidth: 150,
imgMaxHeight: 150,
outputLocation: './outputs',
colorMode: 'fullcolor',
colorCount: '64',
darkColor: 1145324799,
lightColor: 4294910719,
edgeMargin: '50',
pageMargin: '50',
boxSize: '10',
lineColor: '#000000',
breakColor: '10000',
fillOpacity: '0.3' }
(node:4900) UnhandledPromiseRejectionWarning: Error: EEXIST: file already exists, mkdir 'C:\Users\Cortlan Bainbridge\projects\image2pattern\outputs\images'
at fs.mkdirSync (fs.js:872:3)
at Object.fs.mkdirSync (ELECTRON_ASAR.js:727:16)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:71:13)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:77:24)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
at sync (C:\Users\Cortlan Bainbridge\projects\image2pattern\node_modules\mkdirp\index.js:78:17)
(node:4900) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4900) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Expected behavior
Image is generated without error
Screenshots
If applicable, add screenshots to help explain your problem.
Image used
sample_images\AHC_4958.png
Desktop (please complete the following information):
Additional Information
Same thing happens when I click Generate Pattern button as well.
Summary
Remove extraneous white space from the edge of images for black and white patterns.
Is your feature request related to a problem? Please describe.
For black and white patterns white borders are unneeded and just add to the effort of counting, so when the image is being prepared the processor should trim off any extra white space on the edge of the image.
Describe the solution you'd like
When in monochrome mode during the prepImage process any extra white space around the edge of the image should be removed.
Summary
Proper unit tests are needed.
Is your feature request related to a problem? Please describe.
Currently there are a few small test scripts that ensure code is run in many cases, but they aren't true unit tests just short cuts.
Describe the solution you'd like
Unit tests the ensure each method within each module runs properly to the degree possible (testing of generated files is not reasonable at this point since they change a great deal).
The generated patterns should have a bold line every 10 squares to make counting easier.
The black and white versions of the patter need to support using distinct symbols when possible to replace colors in the pattern. Right now the generator using a series of UTF-8 multibyte characters from selected ranges. But the default fonts in PDF from PdfKit don't support these (see foliojs/pdfkit#262). So a different font that does have those characters needs to be embedded.
Currently the gen-test
script cannot run within CircleCI because the files cannot write to the locations in the test script.
See results from: https://circleci.com/gh/acrosman/image2pattern/9
The CircleCI configuration, and the gen-test configuration need to be updated to place the files in a reasonable location.
The last page of patterns with multiple colors is an index of the colors and their DMC threads. Right now that's just a list of text meant to tie to the colors on the pattern itself for support of #7 (and suffering from weaknesses covered in #10). It would be nice to have a little color box next to each entry in the index.
Code to generate existing index:
image2pattern/src/image2pattern.js
Lines 223 to 242 in 0f0aaed
When SVGs are inserted onto pages they don't use as much space as possible. The calculation of their size is off, or they are getting scaled.
The colors each have a symbol assigned. When color patterns are generated it should be possible to print those symbols in the grid instead of the color (or on top of the color), and the next symbol included in the index created for #6.
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.