GithubHelp home page GithubHelp logo

acrosman / image2pattern Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 21.0 7.67 MB

Electron App to convert an image to a cross-stitch pattern.

License: MIT License

JavaScript 88.23% HTML 10.87% CSS 0.90%
electron-app nodejs cross-stitch

image2pattern's People

Contributors

acrosman avatar comets1 avatar dependabot[bot] avatar hiby90hou avatar joeheyming avatar marceloabk avatar oktak avatar sashman avatar sinadshan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

image2pattern's Issues

Support b&w printing of color patterns

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.

Add image editing

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.

Embed font with better UTF-8 Support

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.

Errors getting caught instead of exposed by test script

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:

  1. Setup a new instance of the project without a valid output directory or subdirectories.
  2. npm run gen-test
  3. Note the output reports file permissions errors.

Expected behavior
Errors in test scripts should trigger non-zero response codes. Fixing this should trigger errors in the current code base.

Refactor scripts in tests directory to be proper tests

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.

Add color swatch to index on last page.

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:

if (Object.keys(threadIndex.threads).length > 2) {
// Add key page to the end.
pdfFile.addPage({
margins: {
top: config.pageMargin,
bottom: config.pageMargin,
left: config.edgeMargin,
right: config.edgeMargin,
},
}).text('Adding color key here...', 50, 20);
pdfFile.registerFont('Roboto', 'fonts/Roboto/Roboto-Regular.ttf');
pdfFile.font('Roboto').fontSize(12);
const colors = Object.values(threadIndex.threads);
for (let i = 0; i < colors.length; i += 1) {
pdfFile.text(`${colors[i].symbol} DMC: ${colors[i].DMC} โ€“ ${colors[i].Name}`);
}
console.log(threadIndex.threads);
}

The prep image process should remove white space from image edges

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.

Fix image size on pages

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.

Add support for picking page size.

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.

Resolve file handling on Windows 10

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. npm install && npm start
  2. Click on choose a file and select .\sample_images\AHC_4958.png'
  3. Click generate Image

[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):

  • OS: Windows 10

Additional Information
Same thing happens when I click Generate Pattern button as well.

Add thread index to color patterns

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.

Add unit tests

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).

Would be great to see some examples in the read me

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.

Trim extra white space from the edge of monochrome patterns.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.