Skip to content

Commit

Permalink
Issue 8 fix (#9)
Browse files Browse the repository at this point in the history
* issue 8 reproduced

* issue 8 fix
  • Loading branch information
dgrechka authored Aug 17, 2022
1 parent 3937908 commit 1141a94
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/kafkajobs/serialization/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def imagesNpToStrList(npImages):
# encoding images
for npImage in npImages:
photoPath = os.path.join(tempDir,"{0}.jpeg".format(idx1))
io.imsave(photoPath, npImage)
io.imsave(photoPath, npImage[:,:,:3]) # discarding alpha channel if any
#print("image {0} saved".format(photoPath))
with open(photoPath, 'rb') as photoFile:
photo = photoFile.read()
Expand Down
Binary file added tests/data/issue_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from kafkajobs.jobqueue.queue import JobQueueProducer, JobQueueWorker

class TestSum(unittest.TestCase):
class TestQueues(unittest.TestCase):
def test_pub_sub(self):
consumer = JobQueueWorker('test_consumer',kafkaBootstrapUrl='localhost:9092',topicName='test_topic',appName='test_consumer', replication_factor=1)
producer = JobQueueProducer('localhost:9092', 'test_topic', 'test_producer', replication_factor=1)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import unittest

import kafkajobs.serialization as serialization
import imageio.v2 as imageio

class TestSerialization(unittest.TestCase):
def test_issue8(self):
nparr = imageio.imread('tests/data/issue_8.png')
#print(f'shape {nparr.shape}')
serialized = serialization.imagesNpToStrList([nparr])


if __name__ == '__main__':
unittest.main()

0 comments on commit 1141a94

Please sign in to comment.