1
$\begingroup$

I want to output 100 JPEG Images(in 10 * 10 matrix) in Cloud Application. I came to this code:

ExportForm[
 Grid[Partition[ExportForm[#, "JPEG"] & /@ RandomColor[100], 
   10]], "HTML"]

And deploy:

CloudDeploy[
 ExportForm[
  Grid[Partition[ExportForm[#, "JPEG"] & /@ RandomColor[100], 10]], 
  "HTML"], Permissions -> "Public"]

Get cloud object:

CloudObject["https://www.wolframcloud.com/objects/da4b2681-15f7-4668-9cf2-31d84e4c0634"]

But it gives awkward text:

enter image description here

Question:

  1. Why my code failed to output 10*10 random color matrix?
  2. How to fix it?
$\endgroup$
  • $\begingroup$ Setup a GraphicsGrid expression that gives the desired "10*10 matrix" on the desktop. The deployed graphic should then display without having to wrap it in ExportForm HTML. $\endgroup$ – Christopher Haydock Jan 15 '16 at 1:29
  • $\begingroup$ @ChristopherHaydock CloudDeploy[ExportForm[GraphicsGrid[Partition[RandomColor[100], 10]], "HTML"], Permissions -> "Public"]:wolframcloud.com/objects/396e974a-24f8-4fd1-9834-1718e0959ca2, but only generate 1 image. BTW, Grid gives correct result in my desktop MMA. $\endgroup$ – Sayakiss Jan 15 '16 at 1:37
  • $\begingroup$ A Grid that works on your desktop may still fail when deployed. But a GraphicsGrid that works on your desktop will probably also work in the cloud. $\endgroup$ – Christopher Haydock Jan 15 '16 at 2:00
  • $\begingroup$ Instead of a simple GraphicsGrid it is also possible to deploy an HTML page with a 10 by 10 table of 100 images. Is that what you must have? Or do you want a Grid that is generated by the Mathematica online application? $\endgroup$ – Christopher Haydock Jan 15 '16 at 20:24
  • $\begingroup$ @ChristopherHaydock I want to deploy a application which display n*n images. Basically, I want HTML page with a 10 by 10 table of 100 images this. $\endgroup$ – Sayakiss Jan 16 '16 at 4:25
2
$\begingroup$

GraphicsGrid cloud object:

CloudDeploy[Delayed[
   ExportForm[With[{dimension = 4, pixels = 32}, 
      GraphicsGrid[
         Table[Image[RandomColor[]], {dimension}, {dimension}], 
         Spacings -> 0, ImageSize -> dimension*pixels]],
      "HTML"]], 
   FileNameJoin[{$CloudRootDirectory, "RandomColorGraphicsGrid"}]]

GraphicsGrid cloud object

A much less efficient Grid cloud object that displays a lot of separate images:

CloudDeploy[Delayed[
   ExportForm[With[{dimension = 4, pixels = 32}, 
      Grid[
         Table[
            Image[Table[#, {pixels}, {pixels}] &[RandomColor[]]],
            {dimension}, {dimension}]]],
      "HTML"]], 
   FileNameJoin[{$CloudRootDirectory, "RandomColorGrid"}]]

Grid cloud object

In either case the Delayed gives a new random color set with each call to the cloud object.

$\endgroup$
  • $\begingroup$ Cool. What I want is a lot of separate images, and the second code segment works well for me. Really thanks and sorry for late reply! $\endgroup$ – Sayakiss Jan 19 '16 at 14:43
  • $\begingroup$ I read the document about Delayed, but I did't catch the point why you add a Delayed here. Could you please explain why you add Delayed to your cloud application? -- Okay, I see, without Delayed it will evaluate once and every time I call remains a same picture(not random one). $\endgroup$ – Sayakiss Jan 19 '16 at 14:47
  • $\begingroup$ Thanks for helping improve this answer! $\endgroup$ – Christopher Haydock Jan 19 '16 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.