Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image resize using ImageSharp #349

Closed
ngohungphuc opened this issue Feb 17, 2019 · 2 comments
Closed

Image resize using ImageSharp #349

ngohungphuc opened this issue Feb 17, 2019 · 2 comments
Assignees
Labels

Comments

@ngohungphuc
Copy link
Member

ngohungphuc commented Feb 17, 2019

#321
#326
#337

@ngohungphuc ngohungphuc self-assigned this Feb 17, 2019
@ngohungphuc
Copy link
Member Author

ngohungphuc commented Feb 17, 2019

public void RunImageProcessQueue()
		{
			var factory = new ConnectionFactory() { HostName = "localhost" };
			using (var connection = factory.CreateConnection())
			using (var channel = connection.CreateModel())
			{
				channel.QueueDeclare(queue: QueueName.ImageResizeProcessing.ToString(),
					durable: true,
					exclusive: false,
					autoDelete: false,
					arguments: null);

				//Fair dispatch setup
				channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false);
				Console.WriteLine(" [*] Waiting for messages.");

				var consumer = new EventingBasicConsumer(channel);
				consumer.Received += (model, ea) =>
				{
					var body = ea.Body;
					var assetMessage = Encoding.UTF8.GetString(body);
					Console.WriteLine(" [x] Received {0}", assetMessage);

					var imageName = assetMessage.Split("\\")[1];
					var s =  ProjectPath.ToApplicationPath(imageName);
					var assetPath = $"{ProjectPath.GetApplicationRoot()}\\wwwroot\\{assetMessage}";
					var path = "D:\\SourceCode\\Awesome-CMS-Core\\src\\AwesomeCMSCore\\AwesomeCMSCore";
					using (var image = Image.Load(path))
					{
						image.Mutate(x => x
							 .Resize(295, 205)
							 .Grayscale());
						image.Save(imageName);
					}

					channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
				};

				channel.BasicConsume(queue: QueueName.ImageResizeProcessing.ToString(),
					autoAck: false,
					consumer: consumer);

				Console.WriteLine(" Press [enter] to exit.");
				Console.ReadLine();
			}

Still can't resize eventhough I can load it
cc @AbelianKraun

@AbelianKraun
Copy link
Collaborator

I will check this ASAP when I have time, I'm still configuring the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants